Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run a script contained in a Table?

Status
Not open for further replies.

ton12

Programmer
Mar 9, 2005
58
GB

I have a script contained
in a table called TABA.

How can I run the content of a table TABA?
It contains the following script:

CREATE PROCEDURE PROCTest

AS

CREATE TABLE TESTA
--
--

I would like to create a stored Procedure
PROCTEST and a Table TESTA.

Thanks for your suggestions.

Ton

 
Take the value of the field and put it into a variable, then execute the variable.
Code:
declare @cmd varchar(8000)
SELECT @cmd = Col3
FROM table
WHERE ID = 1
exec (@cmd)

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top