谁能告诉我这个存储过程有什么问题?我只是新来的,正在尝试创建一个新的存储过程,我已经声明了@ctable
. 但是找不到。请帮我
CREATE PROCEDURE [dbo].[sptally]
@cfield varchar(80),
@ctable varchar(30)
AS
BEGIN
SET NOCOUNT ON;
IF OBJECT_ID('dbo.tally') IS NOT NULL DROP TABLE dbo.tally
DECLARE @Counter INT = (Select MAX(CAST(@cfield as bigint)) from @ctable)
SET ROWCOUNT @Counter
SELECT IDENTITY(INT, 1, 1) ID
INTO dbo.tally
FROM master.sys.all_columns c
CROSS JOIN master.sys.all_columns c1
SET ROWCOUNT 0
-- ADD (unique) clustered index
CREATE UNIQUE CLUSTERED INDEX PKC_Tally ON dbo.tally (ID)
END