Differences
This shows you the differences between two versions of the page.
control_sql_-_odbc_process_removal_query [2019/01/27 11:29] |
control_sql_-_odbc_process_removal_query [2019/01/27 11:29] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Explanation of SQL ===== | ||
+ | |||
+ | |||
+ | |||
+ | This query kills all ODBC process in SQL Server that are created for generating reports. | ||
+ | |||
+ | |||
+ | |||
+ | See [[control_error_-_stuck_on_printing_reports]]. | ||
+ | |||
+ | |||
+ | |||
+ | ===== Risk of Data Corruption if Run Improperly ===== | ||
+ | |||
+ | **Moderate**: | ||
+ | |||
+ | |||
+ | |||
+ | ===== SQL ===== | ||
+ | |||
+ | |||
+ | |||
+ | <code sql> | ||
+ | DECLARE @DatabaseName VarChar(20); | ||
+ | Set @DatabaseName = ???; | ||
+ | DECLARE @ProcessId INT; | ||
+ | DECLARE [cursorProcess] CURSOR FOR | ||
+ | select sp.spid | ||
+ | from sys.sysprocesses sp | ||
+ | left join sys.databases db on (sp.dbid = db.database_id) | ||
+ | Where sp.program_name like ' | ||
+ | OPEN [cursorProcess] | ||
+ | FETCH NEXT FROM [cursorProcess] INTO @ProcessId | ||
+ | WHILE @@FETCH_STATUS = 0 | ||
+ | BEGIN | ||
+ | | ||
+ | FETCH NEXT FROM [cursorProcess] INTO @ProcessId | ||
+ | END | ||
+ | CLOSE [cursorProcess]; | ||
+ | DEALLOCATE [cursorProcess]; | ||
+ | </ | ||
+ | |||
+ | **Note: | ||
+ | |||
+ | |||
+ | |||
+ | ===== Version Information ===== | ||
+ | * Entered : 7/23/2009 | ||
+ | * Version : | ||
+ | |||
+ | |||
+ | |||