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
 General SQL Server Forums
 New to SQL Server Programming
 Using Brackets

Author  Topic 

SharkAl
Starting Member

8 Posts

Posted - 2014-07-30 : 17:01:47
Hello all,

I have been using SQL for several years but just starting with my exams and have a question I hope someone can clear up.

When are brackets best used? To my knowledge they are used if you would like a particular part of your statement queried first. Is this right?

When else should they be used?

Thanks

Alan

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-30 : 17:17:41
Do you mean square brackets around an object name or parenthesis? Show us an example and use the bold tag for the part in question.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SharkAl
Starting Member

8 Posts

Posted - 2014-07-31 : 03:43:50
it's ok, I think I have it.

If for example you have Select LEFT('ABC', 3) then the parenthesis are used to contain an expression. Is that right?

The reason I was confused mainly was because they seem to be used on a number of different occasions, to identify columns, expressions etc. Is a good rule of thumb that they are used to contain expressions?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-07-31 : 12:19:07
Not a rule of thumb. It is necessary for functions and also for order of operations.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -