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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server name contains a hyphen (-), now causing problems with scripts

Status
Not open for further replies.

rzirpolo

Programmer
Apr 8, 2002
163
GB
As part of an install procedure I needed to run an "exec" statement against our SQL Server database. The name of the actual Windows 2000 server is "sql-server2k" which causes the statement to come back in error.

We have tried using single as well as double quotation marks but still no luck.

We were going to simply change the server name but SQL Server 2000 is configured to this name and if we amend and therefore restart we won't be able to use SQL to run the statement ?

What I would like to know is,

1) Is there anyway we can amend the statement to run against the server, or can you not reference server names that include a hyphen.

2) A colleague mentioned to me that there is a table that stores what the server name is. Is this true and can you amend it to run this statement ?

Any help on this would be grateful, thanks.
 
use four part name. u can use hyphen in that.

[server-name].[database-name].[owner-name].[object-name]


 
A hyphen isn't really classed as valid in a server name, database name, table name etc.
You can use them though as long as you enclose the name in square brackets []. So in your case try [sql-server2k]
 
Using square brackets when referencing this servername worked fine.

That's excellent and thank you for all the information.
 
Using square brackets when referencing this servername worked fine.

That's excellent and thank you for all the information.

[thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top