Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Stored procedure please...

Status
Not open for further replies.

nc297

Programmer
Apr 7, 2010
162
US
In this table, if Clm and cos have the same numbers and Title = T16 and the other is T2 I want their titles to be called Concurr (this table is what I want the stored procedure to create)

Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 Concurr
S66 454442 454442 06/04/2010 06/13/2010 Concurr
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 Concurr
S66 182659 182659 05/07/2010 05/17/2010 Concurr


This is the table I'm working with called Test. Below I have the create table and insert statements.

Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 T16
S66 454442 454442 06/04/2010 06/13/2010 T2
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 T16
S66 182659 182659 05/07/2010 05/17/2010 T2


CREATE TABLE [dbo].[test](
[doc] [varchar](3) NOT NULL,
[clm] [char](6) NOT NULL,
[cos] [char](6) NOT NULL,
[FileDate] [char](30) NULL,
[DDSRcpt] [char](30) NULL,
[Title] [varchar](3) NOT NULL
) ON [PRIMARY]

insert into test
select 'S66', '454442', '454442', '06/03/2010', '06/11/2010', 'T16' union all

select 'S66', '454442', '454442', '06/04/2010', '06/13/2010', 'T2' union all

select 'S09', '456842', '456842', '07/03/2010', '08/03/2010', 'T16' union all
select 'S66', '157962', '157962', '08/03/2010', '08/03/2010', 'T2' union all
select 'S66', '182659', '182659', '05/04/2010', '05/17/2010', 'T16' union all
select 'S66', '182659', '182659', '05/07/2010', '05/17/2010', 'T2'


I tried this but the results didn't come out right:

SELECT clm, [cos], Title =
case
when clm = [cos] then
'concurr'
End

FROM test



 
Look into ELSE as in CASE WHEN ... THEN ... ELSE ... END

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top