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 |
|
insanepaul
Posting Yak Master
178 Posts |
Posted - 2010-09-01 : 06:33:53
|
| How do I test if 2 fields in a row are equal in value?egIF(SELECT BookingAgentId FROM Job == SELECT BookingOffice FROM Job)THEN SELECT...ELSE SELECT... |
|
|
matty
Posting Yak Master
161 Posts |
Posted - 2010-09-01 : 06:49:00
|
| [code]IF EXISTS(SELECT 1 FROM Job WHERE BookingAgentId = BookingOffice )SELECT..ELSESELECT..[/code] |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-09-01 : 06:49:01
|
| if exists (select 'x' from table_name where BookingAgentId = BookingAgentId and pk_filed=anyvalues )select 'match'elseselect 'not match'Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-01 : 07:17:04
|
| What do you want to do for matches? You want to do something on all rows where there is a match?-- Also, tsql isn't like jave et al. = is both the assignment and equivalence operator.Or do you want to do something if *any* row matches?If you want to do something if there are *ANY* rows like that then use Matty sugestion.if you want to do something to the rows themselves where they match then you'd do an update .... WHERE [bookingAgentID] = [bookingOffice]Maybe you should explain what you want to do and give some sample data.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|