Truncate command using Procedure

  • Hi,

    I want to a procedure to truncate a table and insert record after truncation.But when i run this procedure it gives me the following error -

    "The module 'SP_LPR_DATA' depends on the missing object 'IMMEDIATE'. The module will still be created; however, it cannot run successfully until the object exists." And my procedure is as follows:

    create procedure SP_LPR_DATA

    as

    EXECUTE IMMEDIATE 'delete from Worktrack.dbo.TEST_LPR_Spindle_Agg_Table';

    insert into TEST_LPR_Spindle_Agg_Table select * from Spindle_Agg_View

    go

    Can you please help me what procedure i need to write?

  • EXECUTE IMMEDIATE is not a T-SQL command. Remove the IMMEDIATE and it should work fine as-is

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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