您好,我有關於投射問題的問題。即使結果來自查詢作爲字符串,我得到消息102,級別15,狀態1,行21 '@session_id'附近語法不正確。 然後我試圖使用投射法,但它沒有奏效。如何使用tsql來終止會話
declare @counter int;
declare @session_id int;
set @counter=0;
select
@counter= count(*),
@session_id=cast(req.session_id as int) from sys.dm_exec_requests req where req.command='DbccSpaceReclaim'group by req.session_id
if(@counter>0)
begin
kill @session_id
end
http://stackoverflow.com/questions/15010689/using-kill-with-a-declared-variable可能的重複 –