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

Query "[" 1

Status
Not open for further replies.
Sep 17, 2001
672
US
I have to query off a query. Basically I need to know how I can tell query analyzer to:
SELECT "[Items].[Item Id]" FROM ....
When I do the above it returns the literal string:
"[Items].[Item Id]"

I need to query from a table with field names like:
"[Items].[Item Id]"

How do I tell sql server to query the above literal field name?

The more I learn the more I find I know nothing.

Rob
 
You can use one enclosing set of square brackets and each ] that is not part of the enclosing set of square brackets needs to be escaped with a second ].

i.e.
SELECT [[Items]].[ItemID]]] FROM MyTable
 
Thanks and one last question with this is that I was successfully able to alter the table name using your tip. But I see the old characteristics when I use 'design table' vs 'properties'. When I look at the properties for item_id it says varchar 15 which the altered value but when I use design table I see the old value of varchar 50? Very strange.

The more I learn the more I find I know nothing.

Rob
 
The thing to note is I am pulling this data via a linked server query to an olap server. When I look in design table the column names are like:
"[Measures].[Unit Cost]"

but in properties the column name is:
[Measures].[Unit Cost]

Somehow pulling the data from olap is causing some sort of conflict?

The more I learn the more I find I know nothing.

Rob
 
No, the table name is just showed differently in those two places. In SQL Server 2000, properties shows the literal value of the column name, whereas design table shows an escaped version of it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top