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 2000 Forums
 Transact-SQL (2000)
 How Can I Use ....

Author  Topic 

tanvirasad
Starting Member

10 Posts

Posted - 2006-11-03 : 04:39:28
I have table where I have stored the SQL Statement when I fire the query on that record it shoul run the statement which is stored in that column.

e.g
INSERT INTO MyTable ('Select MyCol From MySecondTable')

When I Run
"Select * From MyTable"
It Should Run
"Select MyCol From MySecondTable"


Tanvir Asad

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-11-03 : 05:51:34
Something like this maybe:
DECLARE @SQL nvarchar(4000)

SET @SQL = (SELECT SQL FROM MyTable WHERE ID = x)

EXEC sp_executesql @SQL


--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-03 : 05:54:42
Missed the single quote around the string

SET @SQL = '(SELECT SQL FROM MyTable WHERE ID = x)'



KH

Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2006-11-03 : 05:57:47
How can we not Cross Post?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74425


Duane.
Go to Top of Page
   

- Advertisement -