Viewing 15 posts - 1,216 through 1,230 (of 1,491 total)
Peter,
Sorry for not being clear.
I was refering to Gary's charindex > 0 test.
April 13, 2007 at 10:27 am
You may need to make sure that parentID <> ChildID in the reference table.
If you have loops in the data I would suggest you get rid of them using iteration.
April 13, 2007 at 9:58 am
SELECT
CAST(LEFT(DataRow, CHARINDEX('A', DataRow) - 1) AS int) AS QuestionNo
,CAST(SUBSTRING(DataRow, CHARINDEX('A', DataRow) + 1, 8000) AS bigint) AS AnswerNo
FROM (
SELECT '02245A555115555155'
) AS YourTable (DataRow)
April 13, 2007 at 9:52 am
Your basic problem is that you need to carry the current parent value through the recursion.
Also, you would probably find it easier if the Reference table was structured better by containing...
April 13, 2007 at 9:00 am
April 13, 2007 at 4:40 am
-- Option 1
-- Dynamic SQL
DECLARE @SQLString nvarchar(4000)
,@Count int
SET @SQLString = N'SELECT @pCount = COUNT(whatever) FROM ' + @ActiveTable
EXEC sp_executesql @SQLString, N'@pCount int OUTPUT', @Count OUTPUT
SELECT @Count
-- Option 2
-- If the...
April 12, 2007 at 11:07 am
or:
UPDATE Membership
SET kMembStatusCode = 2
,StatusDate = GETDATE()
WHERE EXISTS (
SELECT *
FROM OrgsToAppend A
WHERE Membership.OrganisationID = A.OrganisationID
AND A.Member = 1
)
AND kOtherClassDescID = @IDTo
AND MembStatusCode = @Term
April 12, 2007 at 9:37 am
Try:
UPDATE B
SET kMembStatusCode = 2
,StatusDate = GETDATE()
FROM Membership B
JOIN OrgsToAppend A
ON B.OrganisationID = A.OrganisationID
WHERE A.Member = 1
AND B.kOtherClassDescID = @IDTo
AND B.MembStatusCode = @Term
April 12, 2007 at 9:33 am
Maybe:
SELECT T1.*
FROM YourTable T1
JOIN (
SELECT T2.TagName, MAX(T2.[Date]) AS [Date]
FROM YourTable T2
GROUP BY T2.TagName
) D ON T1.TagName = D.TagName
AND T1.[Date] = D.[Date]
ORDER BY T1.[Date] -- DESC
April 12, 2007 at 8:11 am
>>that way you can put your primary key on 1 column (datatype integer) for better performance when joining tables on that key.
‘That would be an ecumenical matter!’
Personally I would think...
April 12, 2007 at 4:43 am
April 12, 2007 at 4:18 am
Maybe you want a composite primary key:
ALTER TABLE YourTable
ADD CONSTRAINT PK_YourTable PRIMARY KEY (a, b, c)
This will stop any duplicates.
April 11, 2007 at 10:52 am
Look up the CONVERT function. There are a number of different formats. eg:
SELECT CONVERT(char(10), SNDF.DateTimeSampled, 103)
April 10, 2007 at 4:02 am
You can use a derived table:
SELECT *
FROM (
SELECT code1
,item
,sec_group =
CASE
WHEN acct_sec = 'foo'
THEN 'group found'
ELSE 'qwerty'
END
,sub_group =
CASE
WHEN group_sec='group found'
THEN 'sub group process'
ELSE group_sec
END
FROM testtable
) D
April 5, 2007 at 9:48 am
Viewing 15 posts - 1,216 through 1,230 (of 1,491 total)