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

  • If I may suggest...

    If this is just for experimentation, that's fine. If this is a design for an app, just don't do this. You're opening yourself to all sorts of complexities, SQL Injection being just one.

    As for how you do this:

    DECLARE @sSQL NVARCHAR(4000)

    SELECT @sSQL = t_sql from t_test WHERE -- whatever condition to get the row you want.

    EXEC (@sSQL)

    Again, DO NOT go this route/design for a real application.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass