好记性不如烂笔头。

存储过程中创建视图

CREATE PROCEDURE [dbo].[存储程名]
  @GHSNAME nvarchar(?)
AS
BEGIN
  EXEC('IF EXISTS (SELECT * FROM sysviews WHERE object_id = ''[dbo].[视图名]'')
  DROP VIEW [dbo].[视图名]')
  EXEC('CREATE VIEW [dbo].[视图名]
  AS
    SELECT [PDNAME],SUM(QUETITY) AS [QUETITY] FROM RCXXJL WHERE [PDNAME]=''显示器'' AND [GHSNAME]='''+@GHSNAME+'''')
END