Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Removing same column from multiple tables?

Author  Topic 

aiken
Aged Yak Warrior

525 Posts

Posted - 2002-02-16 : 16:58:20
Thanks to a little replication mishap, I have 220 tables with a msrepl_tran_version uniqueidentifier column. I need to get rid of all of them, preferably not one by one. Any suggestions?

Thanks
-b

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-02-16 : 17:07:31
You can use the undocumented stored procedure "sp_msforeachtable" to perform a command on each table in the database for example...
 exec sp_msforeachtable 'exec sp_help[ ? ]' 


Taken from the ever helpful... "The Guru's Guide to Transact-SQL"

Justin



Edited by - justinbigelow on 02/16/2002 17:08:14
Go to Top of Page

jbkayne
Posting Yak Master

100 Posts

Posted - 2002-02-16 : 17:11:25
or you could generate the script...

select 'alter table ' + table_name + '
drop column msrepl_tran_version' from information_schema.columns
where column_name = 'msrepl_tran_version'

Go to Top of Page
   

- Advertisement -