Viewing 15 posts - 436 through 450 (of 4,081 total)
As I recall, 2005 doesn't support windowed functions, so you have to deal with any running totals problem (decrementing from a total falls under the category of running totals) in...
July 11, 2016 at 2:10 pm
santiagoc93 (7/9/2016)
with Mycte
as
(
select ROW_NUMBER()over(order by id)as c, t.* from ##TEST as t
)
select t1.DT as "startDate", t2.DT as "endDate"from Mycte as t1
left join Mycte as t2
on t1.ID =t2.ID and t1.c=t2.c-1
Just...
July 11, 2016 at 8:00 am
J Livingston SQL (7/8/2016)
Zidar (7/8/2016)
July 8, 2016 at 1:47 pm
Hey Zidar, here is the function and check constraint to avoid overlap. Can't guarantee it's flawless, I just knocked it out during a break.
I presume you are...
July 8, 2016 at 1:46 pm
How to enforce 2 or 3?
CREATE UNIQUE INDEX IX_#subscriptions ON #subscriptions (SubscriberID, UnsubScribedDate)
will work for our example where the definition of an active subscription is one without an UnsubscribeDate....
July 8, 2016 at 10:26 am
Thank you for putting in the effort to create the constraints.
July 8, 2016 at 10:12 am
A CASE expression is an expression, just like a formula or function.
Its logic produces a single scalar value.
It is not another version of...
July 8, 2016 at 8:39 am
Yes, the MSDN documentation on it isn't very clear, but you can find it on the OUTPUT Clause page in the section on Arguments.
I see it in the syntax...
July 7, 2016 at 5:26 pm
I don't have time to write a paper at the moment, so this will have to suffice. 🙂
I've read Mr. Celko's books, and I have seen some truly execrable flat...
July 7, 2016 at 5:01 pm
If you have the ability to change your transactional code I would suggest this, only because subscriptions are always paired with cancellations.
create table ##TEST (ID int, SubscribeDate date, UnsubscribeDate date)
New...
July 7, 2016 at 2:43 pm
If result.Ip_Code is a number, you could always use it's negative in place of DESC
CASE WHEN result.Pc_CrFCIC IN (52, 53) THEN result.Ip_Code ELSE -result.Ip_Code END,
July 7, 2016 at 1:22 pm
Found one: http://sqlblog.com/blogs/rob_farley/archive/2012/06/12/merge-gives-better-output-options.aspx
Stefanie, not sure why I missed reading your message with the sample code I wanted. But thanks to you as well.
Thanks to you all.
July 7, 2016 at 12:47 pm
Drew, that sounds like the answer to a maiden's prayer, and I'd like to remember it for future reference, but after reading your note I looked at the MSDN pages...
July 7, 2016 at 12:36 pm
DECLARE @Inputs TABLE (RowID INT IDENTITY(1,1) PRIMARY KEY, TextString VARCHAR(100))
insert INTO @inputs
VALUES ('SELECT * from client where id = ''789546'' and county = ''Northants''')
,('select * from client where id =...
July 7, 2016 at 12:26 pm
TheSQLGuru (7/7/2016)
July 7, 2016 at 11:18 am
Viewing 15 posts - 436 through 450 (of 4,081 total)