有誰能告訴我這個存儲過程有什麼問題嗎?我只是新的嘗試創建一個新的存儲過程,我已經聲明@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
是什麼錯誤消息? –
DECLARE @Counter INT =(從@ctable選擇MAX(CAST(@cfield as bigint)) 無法識別...它說需要聲明 –