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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to execute fielddata as sql statement

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2011-01-28 : 02:21:18
Hi,

select pivotname from #pivotdata

My pivotname consist sql statement. How can i execute it using Stored Procedures?

Please advise?

Thank you.

Regards,
Micheale

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-28 : 02:25:33
First explain what are you trying to do? so that we go in the same direction!

Go to Top of Page

micnie_2020
Posting Yak Master

232 Posts

Posted - 2011-01-28 : 02:35:19
TBUser Fieldname: SQL

data of the Fieldname eg: Select * from tbuser where id=1

how to execute the SQL fieldname at the table TBUser?

Thank you.

Regards,
Micheale
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-01-28 : 03:52:48
You will need some form of loop (cursor or while loop) to get record by record and then use Dynamic SQL to execute the statement.

But seriously, are you sure you want to do this ?




read
http://www.sommarskog.se/dynamic_sql.html


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -