Skip to main content
April 2, 2009
Question

dynamic sql stored procedure ?

  • April 2, 2009
  • 1 reply
  • 760 views
Hi,

I have a dynamic table that I need to pass into this stored procedure. I think I'm close, but I'm collecting the following error:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'YAMax'.

Thoughts on how to adjust this procedure?

Thanks,

cfwild
This topic has been closed for replies.

1 reply

Inspiring
April 2, 2009
Try adding the word "into" after the word "select".
Inspiring
April 2, 2009
1. Your @SQLStatement variable is not large enough to hold the dynamic sql string you are using
2. As Dan mentioned the INSERT syntax is incorrect. Though he probably meant INSERT INTO, rather than SELECT INTO.
3. Variables like @TableName variable should _not_ be placed inside the quotes, because they will be treated as literal strings

But is dynamic sql needed? How many of your tables contain those columns?