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 |
|
Jaswinder
Starting Member
8 Posts |
Posted - 2007-05-05 : 06:14:50
|
| Suppose i have a Table name Test and columns Name,spouse .Now i want to write a select statement that should return both columnsbut convert whatsoever value of spouse to null.exampleName Spousea aab bbthen my reult should be like a,null b,nullie always bring both columns but replace the value of Spouse to "" or null. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-05 : 06:22:01
|
[code]select Name, spouce = NULLfrom Table[/code] KH |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-05-05 : 11:03:01
|
or select Name, spouse = ''from Table just increasing my post count Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-05 : 11:07:58
|
dinakar: I'll do you one better at attention to minutiae and boosting post counts. OP wanted the spouse column upper case:select Name, Spouse = NULLfrom Table www.elsasoft.org |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-05-07 : 14:14:38
|
When in rome...[CODE]SELECT Name, NULL AS SpouseFROM Table[/CODE] |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-07 : 14:48:58
|
You guys are impossible!!So why should I stay behind...Here is my attempt:Select Name, NullIf(Spouse, Spouse) SpouseFrom Table Note: NULLIF() to add just extra bit of spice..ahhh.. Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|