locked
insert into and delete in one cursor RRS feed

  • Question

  • Hi,

    Can I execute two statements in one cursor? First SELECT INTO and then DELETE? I have the two statements below:

    1.

    Select 'INSERT INTO Table2 (column1, column2, column3)
    Select column1, column2, column3 FROM '+ OBJECT_NAME(fk.parent_object_id) + ' WHERE Id=''' + @Id + ''''

    FROM sys.foreign_keys fk

    WHERE OBJECT_NAME(fk.referenced_object_id) = 'TableName'

    2.

    select 'DELETE FROM ' + OBJECT_NAME(fk.parent_object_id) + ' WHERE Id=''' + @Id + ''''
    FROM sys.foreign_keys fk
    WHERE OBJECT_NAME(fk.referenced_object_id) = 'TableName'


    Wednesday, December 5, 2012 9:18 AM

Answers

All replies