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 |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2011-05-23 : 16:17:56
|
| I am having a problem with select in query: where attacheddocid is null, how can i make filename='No file' if the attacheddocid=NULLSELECT RecipientType, Email,(select [FileName] from TAB_DocRepository where DocID=AttachedDocid) as DocRepFilename, attacheddocid FROM TAB_Recipients WHERE ModuleID = 22attacheddocid field is INT datatype.I also did this to select in query, but doesn't work: select isnull([FileName],'No File') from TAB_DocRepository where DocID=AttachedDocidThank you very much for the helpful info. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-23 : 16:36:15
|
| SELECT RecipientType, Email,coalesce((select [FileName] from TAB_DocRepository where DocID=AttachedDocid),'No File') as DocRepFilename, attacheddocid FROM TAB_Recipients WHERE ModuleID = 22==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2011-05-23 : 16:40:17
|
| Nigel, Thank you very much.It worked. |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-23 : 16:44:48
|
| Another way isSELECT RecipientType, Email,coalesce([FileName],'No File') as DocRepFilename, attacheddocid FROM TAB_Recipientsleft join TAB_DocRepository on DocID=AttachedDocidWHERE ModuleID = 22==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|