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

  • GilaMonster (12/19/2012)


    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.

    It works,, thanks.. 🙂

    actually from last hour, i want to create a stored procedure which have a dynamic select.. and have a dynamic where too.. and it's really sick for me to create such a dynamic t-sql script...

    so now, i create static stored procedure and it much easier to do.,, thx 4 ur advice man.. 😎