Home Forums SQL Server 2005 Administering Executing sql query from select t_sql from table1 RE: Executing sql query from select t_sql from table1

  • Bhuvnesh (12/19/2012)


    xmozart.ryan (12/19/2012)


    Bhuvnesh (12/18/2012)


    xmozart.ryan (12/18/2012)


    DECLARE @query varchar(255)

    SET @query = (select t_sql from t_test)

    select * from (@query)

    but i got err. msg "Must declare the variable '@query'"

    What yiu actually need here the query as result or data of query ?

    i need the data of query..

    this will work

    DECLARE @query varchar(255)

    SET @query = ''

    SET @query = 'select t_sql from t_test'

    EXEC (@query)

    it's not like that.

    i want to get record set from the query that i already saved on table t_test field t_sql,

    i.e :

    i already saved a sql query like "select * from table" into t_test field t_sql

    after that i want to get that query and save it to variable , and then i want to get record set from that variable..