Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
KILL command
Message
 
 
À
23/07/2003 17:15:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00812948
Message ID:
00812978
Vues:
22
This message has been marked as the solution to the initial question of the thread.
Hi Gerry,

The kill command doesn't allow a local varable as a parameter. You can use dynamic SQL instead.
DECLARE @Cmd VARCHAR(32) 
SET @Cmd = 'KILL ' + CAST(@xspId AS varchar(8)) 
EXEC(@Cmd) 
>I'm trying to kill all connections to a certain database. The following command is successful:
>
>KILL 55
>
>I get an error (Line 12: Incorrect syntax near '@xspid') in the following code on the KILL command. Any ideas?
>
>
>declare @xspid smallint
>
>declare killspids cursor local for
> select spid from master.dbo.sysprocesses where dbid = 7
>open killspids
>
>fetch next from killspids into @xspid
>WHILE @@FETCH_STATUS = 0
>
>begin
>
> kill @xspid
> fetch next from killspids into @xspid
>
>end
>deallocate killspids
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform