我有以下几点:
DECLARE @SchemaName NVARCHAR(MAX)
SET @SchemaName = 'MySchema'
DROP SCHEMA MySchema
我应该怎么去使用这个变量?我试过 DROP SCHEMA OBJECT_ID(@SchemaName)
How should I go to use the variable?
I tried DROP SCHEMA OBJECT_ID(@SchemaName)
也许 DELETE FROM SYS.SCHEMAS WHERE NAME = @SchemaName
等于 DROP
?
试试这个:
DECLARE @sql nvarchar(max), @SchemaName NVARCHAR(MAX)
SET @SchemaName = 'MySchema'
set @sql = 'DROP SCHEMA ' + quotename(@SchemaName)
---print @sql
exec sp_executesql(@sql)
这篇关于使用变量名删除模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!