I am trying to run the following stored procedure. When I click check syntax, I get the error message Incorrect syntax near keyword begin, Incorrect syntax near keyword select
What am i doing wrong ???
declare @spid int, @sql varchar(1000)
select @spid = 10
while exists (select * from master..sysprocesses where spid > @spid and login_time > dateadd(dd,-1,getdate())
begin
select @spid = min(spid) from master..sysprocesses where spid > @spid and login_time > dateadd(dd,-1,getdate()
select @sql = 'kill ' + convert(varchar(20),@spid)
exec (@sql)
end
What am i doing wrong ???
declare @spid int, @sql varchar(1000)
select @spid = 10
while exists (select * from master..sysprocesses where spid > @spid and login_time > dateadd(dd,-1,getdate())
begin
select @spid = min(spid) from master..sysprocesses where spid > @spid and login_time > dateadd(dd,-1,getdate()
select @sql = 'kill ' + convert(varchar(20),@spid)
exec (@sql)
end