Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Drop Table avec variable

3 réponses
Avatar
Etudiant
bonjour
je cherche a effacer une table en utilisant le drop table @MaVariable
mais cela n'a pas l'air de marcher, il me retourne une erreur
Pourquoi?
merci a+

3 réponses

Avatar
Philippe T [MS]
Bonjour,

DECLARE @MySQL nvarchar(4000)
SET @MySQL = 'DROP TABLE ' + @MaVariable
EXEC(@MySQL)

ou encore :

DECLARE @SQLString nvarchar(4000)
DECLARE @ParmDefinition nvarchar(500)

SET @SQLString = 'DROP TABLE @MaTable'
SET @ParmDefinition = '@MaTable nvarchar(200)'
EXECUTE sp_executesql @SQLString, @ParmDefinition, @MaVariable


Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france

"Etudiant" wrote in message
news:#
bonjour
je cherche a effacer une table en utilisant le drop table @MaVariable
mais cela n'a pas l'air de marcher, il me retourne une erreur
Pourquoi?
merci a+


Avatar
Etudiant
Philippe T [MS] a écrit :
Bonjour,

DECLARE @MySQL nvarchar(4000)
SET @MySQL = 'DROP TABLE ' + @MaVariable
EXEC(@MySQL)

ou encore :

DECLARE @SQLString nvarchar(4000)
DECLARE @ParmDefinition nvarchar(500)

SET @SQLString = 'DROP TABLE @MaTable'
SET @ParmDefinition = '@MaTable nvarchar(200)'
EXECUTE sp_executesql @SQLString, @ParmDefinition, @MaVariable


Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france

"Etudiant" wrote in message
news:#

bonjour
je cherche a effacer une table en utilisant le drop table @MaVariable
mais cela n'a pas l'air de marcher, il me retourne une erreur
Pourquoi?
merci a+







merci
Avatar
Philippe T [MS]
Bonjour,

Pas de problème. C'est toujours un plaisir :-)

Phil.
________________________________________________________
Philippe TROTIN http://blogs.msdn.com/ptrotin
Microsoft Services France http://www.microsoft.com/france

"Etudiant" wrote in message
news:
Philippe T [MS] a écrit :
> Bonjour,
>
> DECLARE @MySQL nvarchar(4000)
> SET @MySQL = 'DROP TABLE ' + @MaVariable
> EXEC(@MySQL)
>
> ou encore :
>
> DECLARE @SQLString nvarchar(4000)
> DECLARE @ParmDefinition nvarchar(500)
>
> SET @SQLString = 'DROP TABLE @MaTable'
> SET @ParmDefinition = '@MaTable nvarchar(200)'
> EXECUTE sp_executesql @SQLString, @ParmDefinition, @MaVariable
>
>
> Phil.
> ________________________________________________________
> Philippe TROTIN http://blogs.msdn.com/ptrotin
> Microsoft Services France http://www.microsoft.com/france
>
> "Etudiant" wrote in message
> news:#
>
>>bonjour
>>je cherche a effacer une table en utilisant le drop table @MaVariable
>>mais cela n'a pas l'air de marcher, il me retourne une erreur
>>Pourquoi?
>>merci a+
>
>
>
merci