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)
 Update Syntax

Author  Topic 

IcyMidnight
Starting Member

2 Posts

Posted - 2002-04-04 : 15:16:57
I am VERY new to SQL (a few days). I was wondering what the difference between:
UPDATE Jobs SET [Name]...
and
UPDATE Jobs SET Name...

What do the [] do?

Thanks from a newbie


yakoo
Constraint Violating Yak Guru

312 Posts

Posted - 2002-04-04 : 15:32:39
The [] allows you to reference tables that have special names.

Give a column in your table the name of 'GetDate' and you must use [GetDate] to reference that column.

Give a column in your table the name of 'this is a test' and you must use [this is a test' to reference that column.

Go to Top of Page

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2002-04-04 : 15:34:48
um i forget what they are called but they allow you to use bad names... like

select [this is the name of a column]
from [table with a long name and spaces]

this in practice is bad evil code! stay away! don't use reserved words or things like this in sql ... it just causes headaches and plus your code will be larger because of all the [ & ] ...

Go to Top of Page

IcyMidnight
Starting Member

2 Posts

Posted - 2002-04-04 : 15:40:06
Thank You very much!! A great help. I will keep that in mind when creating table/column names.

Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-04-04 : 15:47:04
I think the term Onamuji is looking for is "Reserverd Words"
Words like Name, Description, etc are reserved by SQL. If you have fields with those names, you should put the [] around them. I think another instance to use [] is if you have spaces in your field names
[Last Name]. I suggest not having spaces if you can avoid it.

Michael

Go to Top of Page
   

- Advertisement -