Syntax error

  • I am trying to run the following SQL Script and it reports the following error message:

    Server: Msg 170, Level 15, State 1, Line 6

    Line 6: Incorrect syntax near 'sp_rename'.

    Unfortunately i dont see anything wrong with the code and was wondering, why is system behaving this way? Is there anything i am missing here?

    Apprecaited any help.

    Cali

    Select Account_Operations,BusOrg,BusPartner,Category,CostCenter,DataSrc,Product,Project,RptBasis,TIMEID,sum(SIGNEDDATA) as SIGNEDDATA,IntCo,SOURCE

    into NEW_tblFACTOperations

    from tblFACTOperations

    Group by Account_Operations,BusOrg,BusPartner,Category,CostCenter,DataSrc,Product,Project,RptBasis,TIMEID,IntCo,SOURCE

    sp_rename tblfactoperations, tblfactoperations_old

    sp_rename NEW_tblfactoperations, tblfactoperations

    CREATE CLUSTERED

    INDEX [IX_TblFactOperations] ON [dbo].[tblFACTOperations] ([Category], [TIMEID], [BusOrg], [Account_Operations], [RptBasis])

    WITH FILLFACTOR = 80

    ON [OperationsD]

  • If a stored proc call is not the first statement in a batch, you need to use the EXEC/EXECUTE command.

    You code should work if you change it as follows :

    Select Account_Operations,BusOrg,BusPartner,Category,CostCenter,DataSrc,Product,Project,RptBasis,TIMEID,sum(SIGNEDDATA) as SIGNEDDATA,IntCo,SOURCE

    into NEW_tblFACTOperations

    from tblFACTOperations

    Group by Account_Operations,BusOrg,BusPartner,Category,CostCenter,DataSrc,Product,Project,RptBasis,TIMEID,IntCo,SOURCE

    EXEC sp_rename tblfactoperations, tblfactoperations_old

    EXEC sp_rename NEW_tblfactoperations, tblfactoperations

    CREATE CLUSTERED

    INDEX [IX_TblFactOperations] ON [dbo].[tblFACTOperations] ([Category], [TIMEID], [BusOrg], [Account_Operations], [RptBasis])

    WITH FILLFACTOR = 80

    ON [OperationsD]

  • Ten,

    Tried the new code (EXEC) and it worked fine. Thanks a million for your assitance.

    Cali

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply