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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Standard Brackets in a LIKE Statement
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

milesnewey
Starting Member

United Kingdom
1 Posts

Posted - 04/11/2013 :  03:00:29  Show Profile  Reply with Quote
Good Morning All.

I am in the midst of a discussion at work regarding the use of standard brackets () in a LIKE statement. For example:

Code sample 1:

UPDATE deblive.scheme.opheadm
SET status ='4'
WHERE status = '3'
AND order_no LIKE('M%')

Code sample 2:

UPDATE deblive.scheme.opheadm
SET status ='4'
WHERE status = '3'
AND order_no LIKE 'M%'

Can anyone please tell me if there is any difference between using standard brackets in a LIKE statement or not? I need this discrepency settled once and for all,

Kind Regards,

Miles

Edited by - milesnewey on 04/11/2013 03:48:22

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 04/11/2013 :  03:22:55  Show Profile  Reply with Quote
no difference

declare @table table
(
field varchar(10)
)
insert @table values ('klhjk'),('mkghjhj'),('m rf'),('kjh'),('ewqf'),('m7656')

select *
from @table
where field like ('m%')

select *
from @table
where field like 'm%'

field
-----------
mkghjhj
m rf
m7656


field
-----------
mkghjhj
m rf
m7656



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000