I have a server with 50 databases all the same with different data but the same structure, is there a way to update a table in multiple databases using the sysdatabases to get the relevant database names from? I imagine it would have to be a cursor to do this? I checked thru the Search feature but could not find any info on this topic is it possible?
you could use something like the system procedure "sp_msforeachdb"...search here for samples of it in use....and it's restrictions (unsupported i think)
you could use something like the system procedure "sp_msforeachdb"...search here for samples of it in use....and it's restrictions (unsupported i think)
Thanks for that you learn something everyday!! I must be missing something but as the following will not run, any ideas? Cheers Phil
declare @sql nvarchar(4000) set @sql = '' select @sql = @sql + 'exec ' + name + '..sp_msforeachtable @command1= ''Update arm set code = ''cash1'' where code = ''cash''''' + char(13) from master..sysdatabases where name <> 'master' and name <>'model' and name <>'pubs' and name <> 'msdb' and name <> 'tempdb' and name <>'northwind' print @sql exec (@sql)