Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005

    Unanswered: Execute Multiple SQL statements in Stored Proc

    Hi, I have a table containing SQl statements. I need to extract the statements and execute them through stored procedure(have any better ideas?)

    Table Test

    Id Description

    1 Insert into test(Id,Name) Values (1,'Ron')
    2 Update Test Set Name = 'Robert' where Id = 1
    3 Delete from Test where Id = 1

    In my stored procedure, i want to execute the above statements in the order they were inserted into the table. Can Someone shed some light on how to execute multiple sql statements in a stored procedure. Thanks


  2. #2
    Join Date
    Jun 2003


    I hope this will help u.
    --Insert statement
    --insert into Test values(1, 'Insert into test(Id,Name) Values (1,''Ron'')')

    declare @sql varchar(8000)
    select @sql=Description from Test where Id=1
    --print @sql
    exec (@sql)
    Last edited by mallier; 11-01-05 at 12:16.

  3. #3
    Join Date
    Jan 2004
    In a large office with bad lighting
    Sounds like homework. What have you tried?

    -- This is all just a Figment of my Imagination --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts