Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Query problems

Author  Topic 

dupati1
Posting Yak Master

123 Posts

Posted - 2003-10-03 : 16:12:37
Hi all,

I have a table named OR Record and one of the columns it has is "Name of Surgeon"

Now my question is how can i write a SQL query if have spaces in the name of the table and also in the name of columns.

Is there anyway i get around around these problems or do i have to compulsorily change my table and column names.??

Example:

If i query something like

SELECT Name of Surgeon from OR Record;

its not working because of the spaces in the names of table and column.

Any suggestions.

Thanks in advance.

VJ

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-03 : 16:15:07
Well you should change the names. But you just need to put brackets around them:

SELECT [Column Name]
FROM [Table Name]

Tara
Go to Top of Page

dsdeming

479 Posts

Posted - 2003-10-06 : 08:40:49
There's more than just spaces going on here. Your industry-standard acronym for operating room has run headlong into SQL Server's reserved words.

SELECT * FROM OR Record generates the following error message: Incorrect syntax near the keyword 'OR'. Tara is right, brackets will solve the problem.

Dennis
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-10-06 : 11:16:54
Yeah..but even though this isn't a cross post...damn sure is close...

RE-ENGINEER THE WHOLE DAMN THING!

ACCESS S_CKS


SELECT REPLACE(COLUMN_NAME,' ','_')
FROM INFORMATION_SCHEMA.Columns





Brett

8-)

SELECT @@POST FROM Brain ORDER BY NewId()

That's correct! It's an AlphaNumeric!
Go to Top of Page
   

- Advertisement -