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 |
|
WeeBubba
Starting Member
18 Posts |
Posted - 2007-01-13 : 21:34:45
|
| i want to return a datase from an SP. but i want to include my own dummy column with custom values.i have a background in Firebird. with Firebird to achieve this I would put my logic after a FOR SELECT/DO clause so that my custom code would run before each row was committed. heres some Firebird pseudo code below. this is the best way to explain it i think. could somebody please tell me how you achieve a similar thing in sql server:CREATE PROCEDURE ...RETURNS( @Id, @Description, @MyCustomValue)FOR SELECT a.Id, a.DescriptionFROM MyTableINTO @Id, @DescriptionDOBEGIN if (...conditional clause...) @MyCustomValue = "Hello" else @MyCustomValue = "World"ENDso my results are like thisId DESCription MyCustomValue------------------------------------------------1 edhuihe Hello2 eddeddd Worldetc |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-01-14 : 03:11:19
|
use CASE WHEN select a.id, a.description, case when (...conditional clause...) then 'Hello' else 'World' endfrom MyTable KH |
 |
|
|
|
|
|