DROP PROCEDURE IF EXISTS [dev].[uspDeleteViewsAll]
GO

CREATE PROCEDURE [dev].[uspDeleteViewsAll]
  @pSchemaName nvarchar(100)
AS BEGIN
  DECLARE @sql nvarchar(max) = ''

  SELECT @sql += N'DROP VIEW IF EXISTS [' + s.name + N'].[' + v.name + N'];' + CHAR(13) + CHAR(10) 
  FROM sys.views v
  INNER JOIN sys.schemas s ON v.schema_id = s.schema_id
  WHERE s.name = @pSchemaName

  EXEC sp_executesql @sql

END
GO
