Wednesday, March 28, 2012

Problem with leading digit in servername?

I have run into trouble since I moved my developmentcode into a production-server.

The production server has a name starting with a digit (i.e. '123server').

The problem occurs when I try to comunicate to another database on the same server, like this:

INSERT INTO 123server.databaseName.tableName VALUES(...)

This gives me the error message "Incorrect syntax near '123'".

Running the exact same code on a server named myServer (without leading digits) works great!

I know that in this case I could change the code into

INSERT INTO databaseName.tableName VALUES(...)

but in the real code, the database server is retrieved from a variable and could or could not be the same server.

Is this a known bug or am I doing something wrong?

regards Andreas Brosten

Try quoting the server name with brackets, like [servername].[databasename]....

When you are doing something like retrieving the name, you should always use [] around them, because you have no idea what could be returned.

|||Oh, of course. I feel like such an idiot!
Thanx pal!

No comments:

Post a Comment