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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to delete duplicate rows with ....
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

asifbhura
Posting Yak Master

India
164 Posts

Posted - 12/18/2012 :  06:22:00  Show Profile  Reply with Quote
Hello,

I have two columns stcode, stname

i have data like
stcode stname
AB001 XYZ
2AB001 XYZ
AB002 AAA
2AB002 AAA

I want to delete all records which are having Stcode which start with 2

regards,

bandi
Flowing Fount of Yak Knowledge

India
2170 Posts

Posted - 12/18/2012 :  06:28:22  Show Profile  Reply with Quote
DELETE FROM TableName
WHERE LEFT(stcode,1) = '2'

--
Chandu
Go to Top of Page

sunriser
Starting Member

14 Posts

Posted - 12/18/2012 :  06:36:28  Show Profile  Reply with Quote
delete from tablename
where
stcode like '2%'

sunriser

Edited by - sunriser on 12/18/2012 06:36:45
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 12/19/2012 :  03:34:52  Show Profile  Reply with Quote
quote:
Originally posted by bandi

DELETE FROM TableName
WHERE LEFT(stcode,1) = '2'

--
Chandu


might cause it to ignore an index if present on stcode column as predicate becomes non sargeable

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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