question

mjftech avatar image
mjftech asked

What is the syntax for using a @variable in Select * Into @variable

I need to create a stored procedure that creates a table for a report application where the tablename is in a local variable: SET @ComsTabName = 'WK_SPTBL_' + @UserID + @VbID SELECT * INTO @ComsTabName FROM gldetail WHERE gldate BETWEEN @FromGLDate AND @ThruGLDate ... I can't use dynamic sql
tsqlstored procedures
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Magnus Ahlkvist avatar image
Magnus Ahlkvist answered
If you can't use dynamic SQL, you can't use dynamic table names either. Unfortunately, it's as simple as that.
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.