07-22-04, 20:00 #1Registered User
- Join Date
- Jul 2004
Unanswered: Executing a Stored Procedure result
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'
and i see the same out , but my indexes and PK still there ... i'm confused about it ..
PLEASE HELP ME OUT
07-22-04, 20:07 #2Registered User
- Join Date
- Jul 2003
- San Antonio, TX
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."