Click here to Skip to main content
16,004,761 members
Home / Discussions / Database
   

Database

 
AnswerRe: sql server 2008 Pin
Shameel14-Nov-09 23:39
professionalShameel14-Nov-09 23:39 
QuestionHow to use the Case in stored procedure Pin
sarang_k13-Nov-09 5:36
sarang_k13-Nov-09 5:36 
AnswerRe: How to use the Case in stored procedure Pin
Abhishek Sur13-Nov-09 5:58
professionalAbhishek Sur13-Nov-09 5:58 
AnswerRe: How to use the Case in stored procedure Pin
Abhishek Sur13-Nov-09 6:00
professionalAbhishek Sur13-Nov-09 6:00 
AnswerRe: How to use the Case in stored procedure Pin
David Skelly13-Nov-09 6:34
David Skelly13-Nov-09 6:34 
GeneralRe: How to use the Case in stored procedure Pin
Mycroft Holmes14-Nov-09 1:59
professionalMycroft Holmes14-Nov-09 1:59 
GeneralRe: How to use the Case in stored procedure Pin
Andy_L_J14-Nov-09 2:38
Andy_L_J14-Nov-09 2:38 
AnswerRe: How to use the Case in stored procedure Pin
Niladri_Biswas14-Nov-09 17:56
Niladri_Biswas14-Nov-09 17:56 
Hi, don't know what is ur actual doubt because the problem stated
sarang_k wrote:
How to use the Case in stored procedure

is a normal thing.



If you are looking for syntax there is plenty in google with examples too.

However, I have given 2 sample for the same program

Sample 1:

Create procedure TestCaseStatement
as

Begin
	declare @tbl table(id int)
	insert into @tbl 
	select 0 union all select 1 union all
	select 2 union all select 1 union all
	select 1
		
	select 
		id
		,case when id = 1 then 'One' else 'Other Number' end as Value	
	 from @tbl
End


Sample 2:

Create procedure TestCaseStatement
as

Begin
	declare @tbl table(id int)
	insert into @tbl 
	select 0 union all select 1 union all
	select 2 union all select 1 union all
	select 1
		
	select 
		id
		,Value = case when id = 1 then 'One' else 'Other Number' end 
	 from @tbl
End


The output

id Value
0	Other Number
1	One
2	Other Number
1	One
1	One



As you can see that I have shown 2 ways of holding the case result into a pseudo column.

And as Mr. Mycroft stated, if you have any specific doubt, please don't hesitate to share it here. We all would love to help you.

Hope you understand and ur doubt as per the question title has been answered.

Have a nice day
Smile | :)

Niladri Biswas

QuestionCreating Records based on Quant Field Pin
ffowler12-Nov-09 7:57
ffowler12-Nov-09 7:57 
AnswerRe: Creating Records based on Quant Field Pin
Mycroft Holmes12-Nov-09 11:35
professionalMycroft Holmes12-Nov-09 11:35 
GeneralRe: Creating Records based on Quant Field Pin
David Skelly12-Nov-09 22:41
David Skelly12-Nov-09 22:41 
GeneralRe: Creating Records based on Quant Field Pin
Mycroft Holmes12-Nov-09 23:05
professionalMycroft Holmes12-Nov-09 23:05 
AnswerRe: Creating Records based on Quant Field Pin
Niladri_Biswas12-Nov-09 16:16
Niladri_Biswas12-Nov-09 16:16 
AnswerRe: Creating Records based on Quant Field Pin
David Skelly12-Nov-09 22:38
David Skelly12-Nov-09 22:38 
GeneralRe: Creating Records based on Quant Field Pin
David Skelly13-Nov-09 0:15
David Skelly13-Nov-09 0:15 
GeneralRe: Creating Records based on Quant Field Pin
ffowler13-Nov-09 1:50
ffowler13-Nov-09 1:50 
GeneralRe: Creating Records based on Quant Field Pin
David Skelly13-Nov-09 2:31
David Skelly13-Nov-09 2:31 
GeneralRe: Creating Records based on Quant Field Pin
ffowler13-Nov-09 2:50
ffowler13-Nov-09 2:50 
QuestionProblem with Datepart Pin
Vimalsoft(Pty) Ltd12-Nov-09 3:10
professionalVimalsoft(Pty) Ltd12-Nov-09 3:10 
AnswerRe: Problem with Datepart Pin
J4amieC12-Nov-09 3:52
J4amieC12-Nov-09 3:52 
AnswerRe: Problem with Datepart Pin
Not Active12-Nov-09 5:36
mentorNot Active12-Nov-09 5:36 
GeneralRe: Problem with Datepart Pin
David Skelly12-Nov-09 5:42
David Skelly12-Nov-09 5:42 
GeneralRe: Problem with Datepart Pin
Not Active12-Nov-09 5:44
mentorNot Active12-Nov-09 5:44 
AnswerRe: Problem with Datepart Pin
David Skelly12-Nov-09 5:42
David Skelly12-Nov-09 5:42 
GeneralRe: Problem with Datepart Pin
Vimalsoft(Pty) Ltd12-Nov-09 22:52
professionalVimalsoft(Pty) Ltd12-Nov-09 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.