1
Reply

Select same table but diffrent database in sql server

jayakrishnan Morayur

jayakrishnan Morayur

Mar 22 2011 12:44 AM
2.1k

i hava 10 more database the database name is 'account_20110310' to 'account_20110320'

the 'Operations' is table of each database are same field ant type

i want to select all field of tabale 'Operations' from all database

i passed the query bellow but occur error

declare @qry nvarchar(max)

SET @qry='SELECT  Operations.* FROM '+

'sys.databases WHERE NAME LIKE account_%'+'..'+'Operations'

EXEC(@qry)

please help me




Answers (1)