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)
 Keywords as fieldnames

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-05-24 : 10:30:09
Peter writes "Hi,

my problem is, that I can't use a keyword as a field name of a table. I switched from Access to SQL Server, but SQL Server behaves different. A statement like

SELECT [DATATYPE] FROM MYTABLE GROUP BY [DATATYPE]

doesn't work. I can't change the name of field because all queries and reports still exist and rely on this name. What should I change to explain SQL Server that this is a field name? I thought I had done it by using []!?

Thanks in advance,
Peter"

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2004-05-24 : 10:30:09
What error message do you get?
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2004-05-24 : 14:28:06
I did not get any error using keyword as column name on sql server 2000
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-24 : 14:47:17
It works for me too:

SET NOCOUNT ON

CREATE TABLE MYTABLE
(
[DATATYPE] int
)

INSERT INTO MYTABLE VALUES(1)
INSERT INTO MYTABLE VALUES(1)
INSERT INTO MYTABLE VALUES(1)
INSERT INTO MYTABLE VALUES(1)
INSERT INTO MYTABLE VALUES(1)

SELECT [DATATYPE]
FROM MYTABLE
GROUP BY [DATATYPE]

DROP TABLE MYTABLE

Peter, see if the code that I posted works for you.

Tara
Go to Top of Page
   

- Advertisement -