mpdillon
asked on
Fully Qualified table name syntax
I would like to write a query accessing two tables using ADO in VB6. The syntax for fully qualified tables names is [server].[databasename].[o wner].[tab le name].
When the server name is SQL2000, the fully qualified name works( Select * from SQL2000.jir.dbo.CusFil ). However, when the server name is fs-jirsql, I receive an error becasue of the hyphen( Select * from fs-jirsq1.jir.dbo.CusFil ). Alternately, I tried the IP address, 10.0.0.120 but the periods in the IP confuse SQL( Select * from 10.0.0.120.jir.dbo.CusFil ).
How do I correctly format the fully qualified table name in a select statement when either the server name contains a hyphen or when I only have the IP address and not the server name?
thanks,
When the server name is SQL2000, the fully qualified name works( Select * from SQL2000.jir.dbo.CusFil ). However, when the server name is fs-jirsql, I receive an error becasue of the hyphen( Select * from fs-jirsq1.jir.dbo.CusFil ). Alternately, I tried the IP address, 10.0.0.120 but the periods in the IP confuse SQL( Select * from 10.0.0.120.jir.dbo.CusFil ).
How do I correctly format the fully qualified table name in a select statement when either the server name contains a hyphen or when I only have the IP address and not the server name?
thanks,
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SQL Server has a long history of not liking the hypen in a name.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much. The square brackets work great with a name that contains a hyphen. However, I tried the IP address in the square brackets and it did not work. I received a message saying to add the server using sp_addlinkedserver. I read a little about this stored procedure but I don't think it is what I want. Is there a way to use the IP address in a fully qualified name?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.