Currently my development environment is using SQL server express 2008 r2 and VS2010 for my project development.
My question is like this by providing a scenario:
Development goal:
I develop window services something like data mining or data warehousing using .net C#. That meant I have a two or more database involved.
my senario is like this:
I have a database with a table call SQL_Stored inside provided with a coloum name QueryToExec.
I first idea that get on my mind is written a stored procedure and i tried to came out a stored procedure name Extract_Sources with two parameter passed in thats ID and TableName.
My first step is to select out the sql need to be execute from table SQL_Stored. I tried to get the SQL by using a simple select statement such as:
Select Download_Sql As Query From SQL_Stored
Where ID=@ID AND TableName=@TableName
Is that possible to get the res开发者_高级运维ult or is there another way to do so?
My Second step is to excecute the Sql that i get from SQL_Stored Table.Is possible to to execute the query that select on the following process of this particular stored proc? Need to create a variable to store the sql ?
Thank you,Appreciate for you all help.Please don't hesitate to voice out my error or mistake because I can learn from it. Thank you.
PS_1:I am sorry for my poor English.
PS_2:I am new to stored procedure.
LiangCk
Try this:
DECLARE @download_sql VARCHAR(MAX)
Select
@download_sql = Download_Sql
From
SQL_Stored
Where
AreaID = @AreaID
AND TableName = @TableName
EXEC (@download_sql)
精彩评论