Viewing 15 posts - 3,181 through 3,195 (of 3,479 total)
You're welcome... if you run my code, make sure the CREATE TABLE code for Protocol is before the code for Enroll. (That part was confusing in my post, I...
January 13, 2014 at 9:12 pm
You can do it using CROSS APPLY.
Read these two articles (definitely worth the read!):
http://www.sqlservercentral.com/articles/APPLY/69953/ (Part I)
http://www.sqlservercentral.com/articles/APPLY/69954/ (Part II)
(Basic plan)
Get the TOP 1 Values from the child table (pass...
January 13, 2014 at 4:19 pm
"I cover this in my Common TSQL Mistakes SQL Saturday session..." (just not #272? Not coming to NashVegas?? Drat!
January 12, 2014 at 6:12 pm
And don't forget MSDB. That's where all your jobs etc are stored.
Before the original server goes away, make sure you have a working SQL Server instance where you need...
January 11, 2014 at 3:01 pm
okay... I think this fixes the "you can't report symptoms after you're dead" issue...
CREATE VIEW vwEnrolleeFatalCycle
AS
SELECT enrollmentID
, MIN(cycle) AS FatalCycle
FROM Symptom INNER JOIN Data ON Symptom.SymptomID = Data.ID
WHERE Grade =...
January 11, 2014 at 12:30 am
Okay, here's the DELETE as a CTE, which is probably the easiest way to do it... (once you read the crib notes)
; WITH CTE_DupeAddr(DupeID, ID, Cid, FName, LName, DOB, City)...
January 10, 2014 at 10:32 pm
So sue me.
--Mark the records we want to delete, just to be sure we don't do anything terrible.
UPDATE #TableA
SET IsActive = 1
WHERE [SID] IN
(SELECT MIN([SID]) AS GoodID
FROM #TableA
GROUP BY ...
January 10, 2014 at 10:03 pm
So in theory they could merge two records that don't match? Could you post an example? Explain why you can't do it with either a CTE or a...
January 10, 2014 at 6:28 pm
Cursor is a bad word around here... careful.
That said, I don't think you need a cursor at all.
CREATE Table #TableA
(
ID int IDENTITY(1,1),
SID INT,
FNAME varchar(50),
LNAMEvarchar(50),
DOB date,
CITYvarchar(50),
IsActive bit
);
GO
INSERT INTO #TableA
VALUES ('245','Smith','John','1/10/1998','Los Angles','0');...
January 10, 2014 at 6:02 pm
Made a little progress. I added some columns just to understand what's going on (since I'm sort of stumbling around in the Dark Ages). Here's my latest attempt:
DECLARE...
January 9, 2014 at 6:50 pm
What's the maximum number of cycles? Can they overlap? Presumably you want a datetime on each symptom row?
As best I can remember, protocols run for a non-predetermined period of...
January 9, 2014 at 3:35 pm
Correct. It's modeling cancer treatment therapy, so sometimes they get fatal complications, and after that you can't test them anymore. (Cheery huh?)
January 9, 2014 at 12:39 pm
Okay, I re-read SQLKiwi's articles on APPLY. Basically, the "left" side is the set of enrollees to "process", and the right side is the symptoms. Got that part....
January 9, 2014 at 10:29 am
Cruel Taskmaster <g>,
I have a dumb question - if I use a non-looping solution, how do I indicate that no more treatment cycles should be added for an enrollee after...
January 9, 2014 at 9:06 am
I probably am skipping a class. The challenge I couldn't get around was this one:
the "continue adding treatment cycles (groups of "symptom" records) until either an enrolled patient has...
January 9, 2014 at 5:56 am
Viewing 15 posts - 3,181 through 3,195 (of 3,479 total)