SQL 2000 Question

Soldato
Joined
6 Jan 2006
Posts
4,663
Location
Newcastle
when i add a table entry in sql with a "-" it comes out with a [] around the item

Note: im using an "_" (underscore) as well in the entries if that makes any difference

for example

test_example-1

then becomes

[test_example-1]

anyway to get past the "[ ]" ???
 
You need it with spaces too.

Is there any reason why you don't want the brackets?
 
You mean it shows with brackets in the enterprise viewer's table list, not just your queries?
 
The hyphen in MSSQL is used as a maths operator, so to use it in a string it needs to be escaped which it does by enclosing the name in square brackets.

If you put the hyphen in the field name you'll see square brackets around it in enterprise manager, and you'll need to add them into every query or stored procedure you write that accesses that field.

protip - don't put hyphens in field names :)
 
Back
Top Bottom