bakershawnm
Programmer
Hello all,
Yesterday the following SQL view and Proc worked fine. Today I only get a single pin in the field.
View used to call concatenate:
SELECT Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug, dbo.GetPins(Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug) AS Pins
FROM (SELECT DISTINCT Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug
FROM dbo.UnusedContacts
UNION
SELECT DISTINCT Drawing, ExtrctDate, RefDes, CavArrngID, [Sealing Plug2]
FROM dbo.UnusedContacts AS UnusedContacts_1
WHERE (NOT ([Sealing Plug2] IS NULL))) AS UnusdCntcs
In the above view the union is because there are two sealing plug fields as you could have up to 2 in any given pin slot.
Concatenate Proc
ALTER FUNCTION [dbo].[GetPins]
(
-- Add the parameters for the function here
@Drwng Varchar(max),
@DtExtrctd DateTime,
@RefDes varchar(max),
@PrtNm varchar(max),
@SlPlg varchar(max)
)
RETURNS Varchar(max)
AS
BEGIN
-- Declare the return variable here
DECLARE @Result Varchar(max)
-- Add the T-SQL statements to compute the return value here
Select @Result = IsNull(@Result + ', ', '') + RTRIM(Pin)
From (Select TOP (100) PERCENT Drawing, ExtrctDate, RefDes, CavArrngID, InsertID, SealingPlug, [Sealing Plug2], Pin,
LEFT(SUBSTRING(Pin, PATINDEX('%[0-9.-]%', Pin), 8000),
PATINDEX('%[^0-9.-]%', SUBSTRING(Pin, PATINDEX('%[0-9.-]%', Pin), 8000) + 'X')-1) as ivalue
From dbo.UnusedContacts) as tmptbl
Where Pin Is Not NULL
And Drawing = @Drwng and RefDes = @RefDes and CavArrngID = @PrtNm
and ExtrctDate = @DtExtrctd and (SealingPlug = @SlPlg or [Sealing Plug2] = @SlPlg)
Order By replace(Pin, ivalue, ''), Cast(ivalue as int)
-- Return the result of the function
RETURN @Result
END
What could possibly cause this to no longer work? Any possibilities will be welcome no matter how unrealistic/improbable they may seem.
And thanks to all of those that contributed (without even knowing it) to the development of this view and Proc setup. I love this site because it is such a great source of information.
Thanks
Yesterday the following SQL view and Proc worked fine. Today I only get a single pin in the field.
View used to call concatenate:
SELECT Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug, dbo.GetPins(Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug) AS Pins
FROM (SELECT DISTINCT Drawing, ExtrctDate, RefDes, CavArrngID, SealingPlug
FROM dbo.UnusedContacts
UNION
SELECT DISTINCT Drawing, ExtrctDate, RefDes, CavArrngID, [Sealing Plug2]
FROM dbo.UnusedContacts AS UnusedContacts_1
WHERE (NOT ([Sealing Plug2] IS NULL))) AS UnusdCntcs
In the above view the union is because there are two sealing plug fields as you could have up to 2 in any given pin slot.
Concatenate Proc
ALTER FUNCTION [dbo].[GetPins]
(
-- Add the parameters for the function here
@Drwng Varchar(max),
@DtExtrctd DateTime,
@RefDes varchar(max),
@PrtNm varchar(max),
@SlPlg varchar(max)
)
RETURNS Varchar(max)
AS
BEGIN
-- Declare the return variable here
DECLARE @Result Varchar(max)
-- Add the T-SQL statements to compute the return value here
Select @Result = IsNull(@Result + ', ', '') + RTRIM(Pin)
From (Select TOP (100) PERCENT Drawing, ExtrctDate, RefDes, CavArrngID, InsertID, SealingPlug, [Sealing Plug2], Pin,
LEFT(SUBSTRING(Pin, PATINDEX('%[0-9.-]%', Pin), 8000),
PATINDEX('%[^0-9.-]%', SUBSTRING(Pin, PATINDEX('%[0-9.-]%', Pin), 8000) + 'X')-1) as ivalue
From dbo.UnusedContacts) as tmptbl
Where Pin Is Not NULL
And Drawing = @Drwng and RefDes = @RefDes and CavArrngID = @PrtNm
and ExtrctDate = @DtExtrctd and (SealingPlug = @SlPlg or [Sealing Plug2] = @SlPlg)
Order By replace(Pin, ivalue, ''), Cast(ivalue as int)
-- Return the result of the function
RETURN @Result
END
What could possibly cause this to no longer work? Any possibilities will be welcome no matter how unrealistic/improbable they may seem.
And thanks to all of those that contributed (without even knowing it) to the development of this view and Proc setup. I love this site because it is such a great source of information.
Thanks