下面是我想删除变量中的视图的代码
declare @tbName nvarchar(max)
set @tbName ='Vw_QueryBuilder_22viewcheckedmergedagain'
exec('IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(' + @tbName + '))
DROP VIEW ' + @tbName)
上面的代码说视图不存在,但它存在我能够显示视图的所有记录