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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to delete duplicate rows with ....

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2012-12-18 : 06:22:00
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-12-18 : 06:28:22
DELETE FROM TableName
WHERE LEFT(stcode,1) = '2'

--
Chandu
Go to Top of Page

sunriser
Starting Member

14 Posts

Posted - 2012-12-18 : 06:36:28
delete from tablename
where
stcode like '2%'

sunriser
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-19 : 03:34:52
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
   

- Advertisement -