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 2005 Forums
 Transact-SQL (2005)
 select [myfile] why square brackets

Author  Topic 

cimonp
Starting Member

1 Post

Posted - 2009-04-07 : 18:07:24
hello

What is the goal behind writing some things in the select query in square brackets?

I came across such a query

Select user_name , [user_file], legend
From user_file)info

why some things are in square brackets?
What will happen if we do not put square brackets?

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-04-07 : 18:10:30
nada, niente, wala hanti, rien , nothing :) sometimes they can be useful for when you do selects from legacy application and field name has space in between [ci monp] or You want to use a system varible such as Date then you would have to use [date] etc. I hate them brackets though.

Just my thought

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2009-04-07 : 18:11:20
[] define object names when those name have weird or illegal chars in them.

___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.5 out!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-08 : 04:05:30
quote:
Originally posted by spirit1

[] define object names when those name have weird or illegal chars in them.

___________________________________________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.5 out!


in addition to keywords like GROUP, ORDER, etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -