Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using sp_tables

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a sp which executes the following sp

EXEC sp_tables

which gets a list of tables in the dbase, but how do I loop through these, as I need to perform an UPDATE query on them??

Cheers
Tim
 
CREATE TABLE #mytemp
(TABLE_QUALIFIER sysname NULL,
TABLE_OWNER sysname,
TABLE_NAME sysname,
TABLE_TYPE varchar(32),
REMARKS varchar(254))

INSERT #mytemp
exec sp_tables

-- DO YOUR STUFF HERE WITH #mytemp
-- CAN USE UPDATE..SELECT
-- OR A CURSOR (ick!)

DROP table #mytemp
 
its basically updating a partnerID field. The tables for there point of sale info are generated dynamically month to month, but sometimes they are finding duplicates in their parter database, with some info attached to one and some to the other. Basically when they find a duplicate they need to run a query that attaches all the details from one partner to the other and then delete the redundant record.

Thanks for the help as well, got it working now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top