quote:
Originally posted by sodeep
See this:
http://www.sqlservercentral.com/Forums/Topic546370-149-1.aspx
Thanks.. I'm using sqlserver 2000 and not sure if this would work for me? I attempted it but, I think its an issue with VARCHAR? There is no MAX. Also we have atleast 60 databases.
Anyone have any ideas? right now i just get the SQL string in the messages tab and it cuts off at like the 9th database
DECLARE @SQL VARCHAR(8000)
SELECT @SQL = COALESCE(@SQL+' UNION ALL'+CHAR(10),'')
+ REPLACE(
' SELECT ''**DBName**'' AS DB_Name,
fundtransactionsource, createdbyuserid, fundtransactiontype,verifieddatetime,transactionid,
fundtransactionlineno, postingdate, tradedate, creationdatetime, fundid, accountnumber,
fundtransactionstatus, grossamount, netamount, shareamount
FROM **DBName**..Fundtransactionlines
WHERE postingdate = ''12/08/08''
AND createdbyuserid NOT in (2,37,38,335)
AND verifieddatetime is null'+CHAR(10),
'**DBName**',Name)
FROM master..Sysdatabases
WHERE name like 'AMD%'
PRINT (@SQL)
EXEC (@SQL)