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 2005 Forums
 Transact-SQL (2005)
 How to delete any record with "*"?

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-07-02 : 14:47:05
How to delete any record with "*"?
For example, the following records should be deleted:

abc*fg
*abc
abc*

TheSQLGuru
SQL Server MVP

10 Posts

Posted - 2009-07-02 : 15:25:11
select * from mytable where myfield like '%*%'

change that to a delete

Kevin G Boles
TheSQLGuru
Indicium Resources, Inc.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-03 : 01:03:57
try this too
select * from mytable where patindex('%*%',myfield)>0

delete from mytable where patindex('%*%',myfield)>0
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-07-03 : 01:22:31
This too will help u..

delete from mytable where charindex('*',myfield)>0


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-03 : 03:53:31
Hi
More info

CHARINDEX returns NULL when the database compatibility level is 70 or later. If the database compatibility level is 65 or earlier, CHARINDEX returns NULL only when both expression1 and expression2 are NULL.
If expression1 is not found within expression2, CHARINDEX returns 0.

Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-07-03 : 05:02:58
quote:
Originally posted by rajdaksha

Hi
More info

CHARINDEX returns NULL when the database compatibility level is 70 or later. If the database compatibility level is 65 or earlier, CHARINDEX returns NULL only when both expression1 and expression2 are NULL.
If expression1 is not found within expression2, CHARINDEX returns 0.





Good and valuable information!

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-03 : 05:12:12
thanks
Go to Top of Page
   

- Advertisement -