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
 Standard Brackets in a LIKE Statement

Author  Topic 

milesnewey
Starting Member

1 Post

Posted - 2013-04-11 : 03:00:29
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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-11 : 03:22:55
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
   

- Advertisement -