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
 query to delete the rows

Author  Topic 

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2012-06-13 : 04:54:29
Hi All,

Iam having a table with as shown below:

MsgID RecipientID RecipientName
3344 0:U: raja
3344 0:U: rakesh
3344 26:U: raja
3344 27:U: rakesh

Now i want a query to avoid/delete the rows with RecipientID column starting with 0 (i.e, 0:U:)

kindly help me on the same

rams

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-06-13 : 04:58:11
delete from urtable where receipientid like '0:U:%';
Go to Top of Page

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2012-06-13 : 05:10:25
hi ahmed,
thanks for your reply, can you also please provide me the query for not inserting the records into the table if recipientid existing with 0:U

Thanks,
Ram

rams
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2012-06-13 : 05:23:59
quote:
Originally posted by jimoomba

hi ahmed,
thanks for your reply, can you also please provide me the query for not inserting the records into the table if recipientid existing with 0:U

Thanks,
Ram

rams



Check constraint can be used to achieve that.

Alter table yourtable add constraint ck_constraint_name check(receipient_id!='0:U')
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-06-13 : 06:30:27
even better, screen out that data on the front end.









How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -