问题描述
我有以下几点:
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)