Click here to Skip to main content
15,912,329 members
Home / Discussions / Database
   

Database

 
AnswerRe: Schema Question Pin
DoctorMick6-Jul-09 6:24
DoctorMick6-Jul-09 6:24 
AnswerRe: Schema Question Pin
David Mujica6-Jul-09 10:23
David Mujica6-Jul-09 10:23 
GeneralRe: Schema Question Pin
Paul Unsworth6-Jul-09 21:42
Paul Unsworth6-Jul-09 21:42 
GeneralRe: Schema Question Pin
David Mujica7-Jul-09 2:57
David Mujica7-Jul-09 2:57 
GeneralRe: Schema Question Pin
Paul Unsworth7-Jul-09 3:14
Paul Unsworth7-Jul-09 3:14 
GeneralAlong with security, consider auditing Pin
David Mujica7-Jul-09 3:25
David Mujica7-Jul-09 3:25 
GeneralRe: Along with security, consider auditing Pin
Paul Unsworth7-Jul-09 4:28
Paul Unsworth7-Jul-09 4:28 
QuestionIF else or Case when Pin
Vimalsoft(Pty) Ltd6-Jul-09 2:34
professionalVimalsoft(Pty) Ltd6-Jul-09 2:34 
Good Day all

i have a two Tables MTM_ACTV_STAFF_CYCLE and MTM_ACTV_STAFF

MTM_ACTV_STAFF

ID | ACTV | STAFF | CYCLETEMPLATE
==================================
1  | 1    | 3     | 3
2  | 4    | 2     | Null


and
MTM_ACTV_STAFF_CYCLE  

ID | IDL  | CYCLE   
=========================
1  | 1    | 3     
2  | 4    | 2    


i have the Following SP

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROC [dbo].[sp_Get_Staff_Cycles] 
(
@Subject_Descr varchar(30)
)
AS
--Check if the table Exists 
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FINAL]'))
drop table [FINAL]
--Get the Cycle template description
Declare @CycletemplateTerm varchar(60)
set @CycletemplateTerm = (  select top 1 t.descr from MTM_ACTV_STAFF mtn
							inner join tbl_actv a on a.id  = MTN.actv
							inner join tbl_cntc cc on a.cntcID = cc.id
							inner join tbl_modl m on m.id = cc.modlid
							inner join tbl_term t on a.term = t.id 
							LEFT OUTER JOIN MTM_ACTV_STAFF_CYCLE C
							ON C.IDL = MTN.ID
							WHERE M.DESCR = @Subject_Descr
						)
 
SELECT [ID] = IDENTITY (int,1,1),A.DESCR AS [ACTIVITY], S.DESCR,
CASE MTN.CYCLETEMPLATE WHEN NULL THEN  C.CYCLES
ELSE @CycletemplateTerm
END AS CYCLETEMPLATE
INTO FINAL FROM TBL_STAFF S
INNER JOIN MTM_ACTV_STAFF MTN ON
S.ID = MTN.STAFF
inner join tbl_actv a on a.id  = MTN.actv
inner join tbl_cntc cc on a.cntcID = cc.id
inner join tbl_modl m on m.id = cc.modlid
LEFT OUTER JOIN MTM_ACTV_STAFF_CYCLE C
ON C.IDL = MTN.ID
WHERE M.DESCR = @Subject_Descr


now in the above Sp i have the Following Problem. In this Line of code
CASE MTN.CYCLETEMPLATE WHEN NULL THEN  C.CYCLES
ELSE @CycletemplateTerm
END AS CYCLETEMPLATE


If the field CYCLETEMPLATE in MTM_ACTV_STAFF table is null i want to use the Values found in table MTM_ACTV_STAFF_CYCLE and Field CYCLES
and another condition again, if there is a value in the MTM_ACTV_STAFF and on the CYCLETEMPLATE then
use the Value in the Variable @CycletemplateTerm

Now my Problem is that instead of bringing 3 its Brings a Sting "Year". there is Prbably something Wrong in my Condiution. Can you please help me in that Regard

Thanks

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: IF else or Case when Pin
DoctorMick6-Jul-09 6:28
DoctorMick6-Jul-09 6:28 
GeneralRe: IF else or Case when Pin
Vimalsoft(Pty) Ltd6-Jul-09 19:58
professionalVimalsoft(Pty) Ltd6-Jul-09 19:58 
QuestionSelect null value Pin
yesu prakash6-Jul-09 2:20
yesu prakash6-Jul-09 2:20 
AnswerRe: Select null value Pin
Eddy Vluggen6-Jul-09 3:28
professionalEddy Vluggen6-Jul-09 3:28 
AnswerRe: Select null value Pin
Niladri_Biswas6-Jul-09 15:51
Niladri_Biswas6-Jul-09 15:51 
QuestionSQL Stored Procedure INSERT with random records from a 2nd table [modified] Pin
munklefish6-Jul-09 0:46
munklefish6-Jul-09 0:46 
AnswerRe: SQL Stored Procedure INSERT with random records from a 2nd table Pin
DoctorMick6-Jul-09 1:05
DoctorMick6-Jul-09 1:05 
GeneralRe: SQL Stored Procedure INSERT with random records from a 2nd table Pin
munklefish6-Jul-09 1:09
munklefish6-Jul-09 1:09 
GeneralRe: SQL Stored Procedure INSERT with random records from a 2nd table Pin
Blue_Boy6-Jul-09 6:11
Blue_Boy6-Jul-09 6:11 
GeneralRe: SQL Stored Procedure INSERT with random records from a 2nd table Pin
munklefish7-Jul-09 0:04
munklefish7-Jul-09 0:04 
Questioni neeed help Pin
mahmoudinirat5-Jul-09 23:32
mahmoudinirat5-Jul-09 23:32 
AnswerRe: i neeed help Pin
DoctorMick6-Jul-09 0:00
DoctorMick6-Jul-09 0:00 
QuestionWant to understand how to fine tune stored procedure in SQL Server 2005? Pin
Sasmi_Office5-Jul-09 20:12
Sasmi_Office5-Jul-09 20:12 
AnswerRe: Want to understand how to fine tune stored procedure in SQL Server 2005? Pin
Blue_Boy5-Jul-09 22:10
Blue_Boy5-Jul-09 22:10 
QuestionTime Difference w.r.t Dates Pin
AliAmjad5-Jul-09 19:37
AliAmjad5-Jul-09 19:37 
AnswerRe: Time Difference w.r.t Dates Pin
Blue_Boy5-Jul-09 20:41
Blue_Boy5-Jul-09 20:41 
GeneralRe: Time Difference w.r.t Dates Pin
AliAmjad5-Jul-09 21:01
AliAmjad5-Jul-09 21:01 

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.