Re: Run same query against multiple tables



Gav,

There is the undocumented stored procedure: sp_msforeachtable

It will execute the command specified for the databases on your server. It
is fairly flexible, but (as mentioned) is undocumented and therefore
unsupported. You can also look at the code to see how it is doing the work
and then imitate that in your own code.

RLF

"Gav" <Gav@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2A4731B4-4D3C-4D29-BA90-88FD2905D2A8@xxxxxxxxxxxxxxxx
Hi all,

Is there a way to quickly run an sql query against all the tables in a
database? or will I have to simply write a line for each table? I have
100+
tables where I want to delete rows from from them where ID= (a particular
id).

Thanks
Gav


.



Relevant Pages

  • 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... the server. ... MSDE either from the Setup or from the SQL2KDeskSP3 execute. ... it does look like some of the sample databases have been ... >> and they directed me to install MSDE and they attached a ConfigSamples ...
    (microsoft.public.sqlserver.msde)
  • Re: 2nd Post - Trouble Getting VS.Net 2003 WalkThrough working
    ... The fact that the other databases exists phyiscally doesn´t mean that they ... can try to connect to SQL Server using OSL or a GUI. ... The Command OSQL ist for the commandline under DOS. ... > this MSDE either from the Setup or from the SQL2KDeskSP3 execute. ...
    (microsoft.public.sqlserver.msde)
  • Re: Cannot Drop Users
    ... "Zekske" wrote in message ... I attached databases from a SQL7.0 server in domain A on a SQL 2000 server ... when I execute SP_Change_users_login 'report', ...
    (microsoft.public.sqlserver.security)
  • Re: SQL Enable FullText automaticly on reboot
    ... Create a stored procedure and mark it as a startup stored procedure ... > Is there a way to execute the sp_fulltext_enable stored proc automaticly ... > after a server rebooted on all the databases in the server? ...
    (microsoft.public.sqlserver.programming)
  • Re: AS2005 ... what is wrong with it?
    ... What I have seen is that the dev server is *faster* than the prod server ... And does your dev server also have all 6 databases with all these roles? ... When I restore the "PROV" i got approx 20 sec. ... Starting from an empty data folder should show if this theory is true ...
    (microsoft.public.sqlserver.olap)