Home Forums SQL Server 2005 T-SQL (SS2K5) Creating Database Objects from a Trigger-invoked stored procedure.... RE: Creating Database Objects from a Trigger-invoked stored procedure....

  • Thank you for your reponse. Since I am new at this, do you know where I can find an example of the USE statement in a dynamic SQL statement?

    I used this one, but it did not seem to work:

    SET @sql = 'USE [' + @strDBName + ']';

    EXEC (@SQL)

    Then I try to create the view...

    SET @sql = 'CREATE VIEW .....

    EXEC (SQL)

    After the procedure runs, the view is created but in the original database, not the new one specified.

    Thank you very much.