You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT session_id, TEXTFROMsys.dm_exec_connections c
CROSS APPLY sys.dm_exec_sql_text(c.most_recent_sql_handle) AS ST
WHEREc.session_id=**{session_id}**
通过mdf和ldf创建数据库
CREATE DATABASE **{name of db}**-- eg: 'C:\workspace\data\mydb_new.mdf'ON (FILENAME ='**{path to mdf file}'),
-- eg: 'C:\workspace\data\mydb_new_log.ldf'
(FILENAME ='**{path to ldf file}')
FOR ATTACH;
批量禁用外键 Foreign key(用于临时脏数据清理)
-- Disable all the constraint in database
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"**{your maintenance sql goes here}**-- Enable all the constraint in database
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"