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

asifbhura
Posting Yak Master

India
165 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
2241 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
52326 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  
 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