Advertisement

07.07.2008 at 05:01PM PDT, ID: 23545133
[x]
Attachment Details

Stored Procedure Variable declaration Assistance

Asked by NursingCorp in MS SQL Server, SQL Server 2005

Tags: Microsoft, SQL, 2005

Please see the attached code snippet. The sp will work when all of the variable are passed. How do I get it to show all records when no variables are declared. I have tried to set the initial value equal to '%' but it did not work.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
 
 
 
ALTER PROC [dbo].[spNC_GetJobBoard]
 @License nvarchar(50) = '',
 @Specialty nvarchar(50) = '',
 @Location nvarchar(50) = '',
 @Type nvarchar(50) = ''
 
 
AS
SET NOCOUNT ON
 
IF OBJECT_ID('tempdb..#tmpJobData') IS NOT NULL
	DROP TABLE #tmpJobData
 
 
IF OBJECT_ID('tempdb..#tmpFacData') IS NOT NULL
	DROP TABLE #tmpFacData
 
SELECT DISTINCT XModID, [value] as Facility, 
(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'C_State' and mask = 1 and XModID = F.XModID) as State,
(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'C_City' and mask = 1 and XModID = F.XModID) as City
INTO #tmpFacData
FROM KB_XMod_Index_VC50 F
WHERE [key] = 'C_CustomerName'
 
SELECT DISTINCT XModID, 
	(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_ShiftTime' and mask = 2 and XModID = B.XModID) as ShiftTime,
    (SELECT [value] FROM KB_XMod_Index_VC100 WHERE [key] = 'B_FacilityName' and mask = 1 and XModID = B.XModID) as Facility,
	(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_LicenseRequested' and mask = 1 and XModID = B.XModID) as LicReq,
	(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_SpecialtyRequested' and mask = 1 and XModID = B.XModID) as SpecReq,
	(SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_Status' and mask = 1 and XModID = B.XModID) as Status,
	(SELECT [value] FROM KB_XMod_Index_VC400 WHERE [key] = 'B_ExternalJobDesc' and mask = 1 and XModID = B.XModID) as JobDesc,
    (SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_AssignmentLength' and mask = 1 and XModID = B.XModID) as Length
INTO #tmpJobData
FROM KB_XMod_Index_VC50 B
WHERE (SELECT [value] FROM KB_XMod_Index_VC50 WHERE [key] = 'B_Status' and mask = 1 and XModID = B.XModID) IN ('Per-Diem Job Order', 'Travel Job Order', 'Perm Job Order')
 
UPDATE #tmpJobData
SET Status = 'Travel' WHERE
Status = 'Travel Job Order'
 
UPDATE #tmpJobData
SET Status = 'Per-Diem' WHERE
Status = 'Per-Diem Job Order'
 
UPDATE #tmpJobData
SET Status = 'Perm Plcmt' WHERE
Status = 'Perm Job Order'
 
UPDATE #tmpJobData
SET Length = 'N/A' WHERE
Length IS NULL OR Length = ' '
 
UPDATE #tmpJobData
SET JobDesc = '<font face=verdana size=2>On going Local Per-Diem position</font>' WHERE
JobDesc IS NULL OR JobDesc = ' '
 
SELECT DISTINCT J.XModID, J.ShiftTime, J.Facility, J.LicReq, J.SpecReq, J.Status, J.Length, J.JobDesc, (F.City + ', ' + F.State) as Location, 'ApplyNow/tabid/134/Default.aspx' as LinkData
FROM #tmpJobData J, #tmpFacData F
WHERE J.Facility = F.Facility 
AND J.LicReq = @License 
AND J.Status = @Type
AND J.SpecReq = @Specialty
AND F.State = @Location
[+][-]07.07.2008 at 05:24PM PDT, ID: 21949814

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 05:39PM PDT, ID: 21949864

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 06:09PM PDT, ID: 21949959

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 06:46PM PDT, ID: 21950133

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, SQL Server 2005
Tags: Microsoft, SQL, 2005
Sign Up Now!
Solution Provided By: acperkins
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628