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 |
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-03-04 : 08:11:49
|
| How can I read one column and based on its value, populate an aliased column (does not exist in the table), which will be used to create a csv file?I assume CASE will do it, just not sure of the syntax when assigning the values to the aliased field.SELECT CASE WHEN service_code = 'Regular Inquiries' THEN test = 'Checking Service' ELSE test = 'Testing'END AS test, service_code FROM data_cert_template |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-04 : 08:15:10
|
| SELECT CASEWHEN service_code = 'Regular Inquiries' THEN 'Checking Service'ELSE 'Testing'END AS test FROM data_cert_template |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-04 : 08:16:56
|
| orSELECT test=CASEWHEN service_code = 'Regular Inquiries' THEN 'Checking Service'ELSE 'Testing'END , service_code FROM data_cert_templateMadhivananFailing to plan is Planning to fail |
 |
|
|
qman
Constraint Violating Yak Guru
442 Posts |
Posted - 2009-03-04 : 08:25:15
|
| Great, thanks guys. madhivanan...., just what I was looking for! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-04 : 09:07:54
|
quote: Originally posted by qman Great, thanks guys. madhivanan...., just what I was looking for!
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|