drop all user view in sql server database
DECLARE @sqlExecute VARCHAR(MAX) = ''
, @crlf VARCHAR(2) = CHAR(13) + CHAR(10) ;
SELECT @sqlExecute = @sqlExecute + 'DROP VIEW ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(v.name) +';' + @crlf
FROM sys.views v
--PRINT @sqlExecute;
EXEC(@sqlExecute);
DECLARE @sqlExecute VARCHAR(MAX) = ''
, @crlf VARCHAR(2) = CHAR(13) + CHAR(10) ;
SELECT @sqlExecute = @sqlExecute + 'DROP VIEW ' + QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(v.name) +';' + @crlf
FROM sys.views v
--PRINT @sqlExecute;
EXEC(@sqlExecute);
No comments:
Post a Comment