Drop A Schema Using Variable Name
I have the following: DECLARE @SchemaName NVARCHAR(MAX) SET @SchemaName = 'MySchema' DROP SCHEMA MySchema How should I go to use the variable? I tried DROP SCHEMA OBJECT_ID(@Sche
Solution 1:
Try something like this:
DECLARE@sql nvarchar(max), @SchemaName NVARCHAR(MAX)
SET@SchemaName='MySchema'set@sql='DROP SCHEMA '+ quotename(@SchemaName)
---print @sqlexec sp_executesql(@sql)
Post a Comment for "Drop A Schema Using Variable Name"