joining 2 databases SQL

Associate
Joined
11 Aug 2005
Posts
1,337
Location
Essex
Hi,

I am trying to write a simple sql script to join to tables together on different databases.

This in it self is normally quite simple
Code:
select * from extractsql1..tenagree 
inner join extractsql2..RentTransactions blah blah blah

except that the extract1 database is actually called 630_extract1

when I try and join this table together I get this error
Code:
Line 1: Incorrect syntax near '630'.

Which I believe that is because the DB name starts with a number.

I have no idea why it was set up in this way and renaming the database is the very very last option. Is there any way to get around this?

I can't create a copy of the database as this is a report that is going to get run regularly and the database is updated all the time.

Thanks in advance
 
Which database manager are you using? I know most will only allow you to connect to (and hence query) one database at a time and you have to do fancy stuff to get round it.
 
Hi guys,

I am using query analyser

fixed the issue by using square brakets

Code:
select * from [630_extract1].dbo.tenagree

thanks for your help
 
Back
Top Bottom