Showing posts with label reference. Show all posts
Showing posts with label reference. Show all posts

Wednesday, March 21, 2012

Problem with Hyphen in server name?

Hi all, My sql server has a hyphen in its name, and I've noticed I can't use a fully qualified reference, server.database.owner.table. Is this a known bug?, what's the fix apart from renaming?

This is standard version, not a beta.

Hi Meltdown,

this is anugly things having a hyphen,or any other character in the server name, but putting brackets around that should solve the problem.

[server].database.owner.table

HTH, Jens Suessmeyer.

|||

Thanks for the reply Jens, unfortunately the brackets don't seem to solve it, I now get the following error when I run my code

Select [DYFLIN-SQL].DyflinSQLDB.dbo.tblGroups.GroupName From tblGroups;

Msg 4104, Level 16, State 1, Line 6

The multi-part identifier "DYFLIN-SQL.DyflinSQLDB.dbo.tblGroups.GroupName" could not be bound.

|||

Try with

set quoted_identifier off

Select "DYFLIN-SQL".DyflinSQLDB.dbo.tblGroups.GroupName From tblGroups;

GO

Cheers,

Sunny

|||Thanks for trying Sunny, that doesn't work, it returns the following error:

Msg 258, Level 15, State 1, Line 5

Cannot call methods on varchar

...although GroupName is of datatype nvarchar

|||

Could it be something like :

Select a.groupName from [DYFLIN-SQL].DyflinSqlDB.dbo.tblGroups as a ?

|||Thanks a lot Jp, you've cracked it, that works perfectly, much appreciated.|||You're welcome! ;)