Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Problem with query

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-17 : 05:03:10
Dear Experts,
an you please tell me what is the problem there in my query?

SELECT *,ROWNUM = IDENTITY (INT, 1, 1) INTO #T FROM +'(' + @A + ')'+ TAB order by chk

thanks in advance

Vinod
Even you learn 1%, Learn it with 100% confidence.

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2007-05-17 : 05:12:35
Table Name cannot be specified dynamically like this..
Use dynamic sql
Set @sql = 'SELECT *,ROWNUM = IDENTITY (INT, 1, 1) INTO #T FROM (' + @A + ') TAB order by chk'
exec @sql
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-05-17 : 05:15:57
Thank you gupta for the solution, can you please see the procedure post of me? there, can i modify this with @A ?



Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-05-17 : 07:37:31
More on dynamic sql
www.sommarskog.se/dynamic_sql.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -