Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    12

    Unanswered: Executing a Stored Procedure result

    Hi Guys..

    How Can i Execute a result from a StoredProcedure... I got a sp that generates drop index and pk from all tables in the DB..

    I got this results from running (sp_dropallindex) like this:

    ALTER TABLE Table1 DROP CONSTRAINT PK_Table1 GO
    ALTER TABLE Table2 DROP CONSTRAINT PK_table2 GO
    DROP INDEX table1.index1 GO
    DROP INDEX table1.index2 GO

    I need to execute that result.. I know that i can copy/paste into Query Analyzer and then run it but how can i handle that result and run all in shot ...

    I tried something like this:

    DECLARE @DROP AS VARCHAR(8000)
    SET @DROP='exec sp_drop_allindex'
    EXECUTE (@DROP)

    and i see the same out , but my indexes and PK still there ... i'm confused about it ..

    PLEASE HELP ME OUT

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    I'd use BCP with QUERYOUT and then OSQL against the output file.

    BCP "exec db_name.dbo.sp_dropallindexes" queryout drop_all_indexes.sql /S server_name /T
    OSQL -i drop_all_indexes.sql -S server_name -E -d db_name
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •