SQL Server Forums
Profile | Register | 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
 New Topic  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
52317 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000