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.
| 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 RecipientName3344 0:U: raja3344 0:U: rakesh3344 26:U: raja3344 27:U: rakeshNow i want a query to avoid/delete the rows with RecipientID column starting with 0 (i.e, 0:U:) kindly help me on the samerams |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2012-06-13 : 04:58:11
|
| delete from urtable where receipientid like '0:U:%'; |
 |
|
|
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:UThanks,Ramrams |
 |
|
|
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:UThanks,Ramrams
Check constraint can be used to achieve that.Alter table yourtable add constraint ck_constraint_name check(receipient_id!='0:U') |
 |
|
|
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.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|
|