[Microsoft][SQL Native Client][SQL Server]Invalid column name 'F2'.
Код:
DECLARE @VTABLEID INT, @VNEXTRECID BIGINT,@TMP_ROW_CNT BIGINT;
SET @VTABLEID = 2832;
DECLARE C_F CURSOR FOR
SELECT NEXTVAL FROM SYSTEMSEQUENCES WHERE ID = -1 AND TABID = @VTABLEID FOR UPDATE;
BEGIN
IF OBJECT_ID(N'TEMPDB..#DEL_UPGRADEBUSRELTABLE_TMP') IS NOT NULL
DROP TABLE #DEL_UPGRADEBUSRELTABLE_TMP
SELECT CONVERT(NVARCHAR(20),'') AS F3,BUSRELACCOUNT AS F1,RECID AS F2 , DEL_CUSTACCOUNT as F4 , DEL_VENDACCOUNT as F5 , DATAAREAID AS DATAAREAID, 1 AS RECVERSION, IDENTITY(BIGINT,1,1) AS RECID INTO [#DEL_UPGRADEBUSRELTABLE_TMP] FROM SMMBUSRELTABLE A WHERE (DATAAREAID= N'ATC') AND PARTYID = ' ' UPDATE #DEL_UPGRADEBUSRELTABLE_TMP SET F3 = [dbo].FN_FMT_NUMBERSEQUENCE('',RECID,12,0);
SET @TMP_ROW_CNT =( SELECT COUNT(RECID) FROM #DEL_UPGRADEBUSRELTABLE_TMP)
OPEN C_F
FETCH NEXT FROM C_F
INTO @VNEXTRECID
UPDATE SYSTEMSEQUENCES SET NEXTVAL = NEXTVAL + @TMP_ROW_CNT WHERE ID = -1 AND TABID = @VTABLEID;
CLOSE C_F
DEALLOCATE C_F
INSERT INTO DEL_UPGRADEBUSRELTABLE (PARTYID,BUSRELACCOUNTID,BUSRELRECID ,CUSTACCOUNTID ,VENDACCOUNTID ,DATAAREAID,RECVERSION,RECID)
SELECT F3,F1,F2 ,F4 ,f5 ,DATAAREAID,RECVERSION,RECID+@VNEXTRECID FROM #DEL_UPGRADEBUSRELTABLE_TMP
IF OBJECT_ID(N'TEMPDB..#DEL_UPGRADEBUSRELTABLE_TMP') IS NOT NULL
DROP TABLE #DEL_UPGRADEBUSRELTABLE_TMP
END;