Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing database with '-' in the name

Status
Not open for further replies.

Luvsql

Technical User
Apr 3, 2003
1,179
CA
A user database was created with a name like data-base (ie - in the middle of the name). When I try and query the db or do anything referencing data-base.dbo.table, I receive an error because of the -. Is there anyway around this without having to rename the db?
 
use syntax:

[data-base].dbo.table

best regards
Chris
 
the same problem can occur if table has '-' or space inside name. This syntax always works (if names does not contain any characters that are not allowed)

[data base name].[owner name].[table name]


alternatively you can change [ ... ] with ' ... ' notation

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top