CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123

    Execute a sentence into a procedure (SQL Server)

    I have declared a varchar variable, and it contains a sql sentence (which it works), I want to execute this sentece into a procedure.
    If I use:
    EXECUTE @sentence;

    I get this error: "insert into..... (all sentence)" isn't a valid identifier.

    How can I do that?
    Thank you in advance.
    I am Miss Maiden... Miss Iron Maiden :-D

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    maybe you need to use ( )
    something like this :
    Code:
    declare @sentence varchar(100)
    set @sentence='select * from employees'
    exec (@sentence)
    which works fine.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured