Forum Replies Created

Viewing 15 posts - 811 through 825 (of 14,953 total)

  • RE: Stored Procedure help

    Eugene Elutin (9/17/2012)


    a bit shorter version...

    DECLARE @year int

    SET @year = 2015

    SELECT

    MONTH(mfd) AS MonthNo

    ...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Stored Procedure help

    ScottPletcher (9/14/2012)


    Code below has fewer calcs and does not depend on any SQL date settings.

    DECLARE @year int

    SET @year = 2012 --<<-- chg as needed

    SELECT

    month_start,

    ...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: rCTE vs LIKE for Hierarchy

    On the I/O, the high reads+scans on rCTEs are because it has to check each row that comes up for children rows.

    Example (simple) hierarchy:

    1 null

    2 1

    3 1

    4 2

    5 2

    6 3

    7...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: rCTE vs LIKE for Hierarchy

    Jeff Moden (9/14/2012)


    GSquared (9/13/2012)


    ...

    Tests that don't involve any table-query, just Insert statements, or a RAM-resident Select (like the cCTE), don't test all the factors in building an adjacency hierarchy crawl...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: T-SQL Help Needed

    CELKO (9/14/2012)


    First, email is so obviously not a natural key for a human being that I'm always shocked when people try to use it that way. It's fine...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Searching the time data type

    L' Eomot Inversé (9/15/2012)


    Unless there is some performance issue that I haven't spotted, it should be sensible to do this the simple and obvious way:

    SELECT LoadNumber

    FROM LoadTimes...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Need to get YYYYMM from date ?

    balajisrm (9/15/2012)


    But this one is not working for SELECT CONVERT(CHAR(6), '2012-09-15', 112);

    i mean When we provide a hard coded date.

    As mentioned, you need to convert that string to...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Using Print, will it slow down procedure?

    I have to say I think the argument is kind of pointless.

    I'd need to see some sort of proof, or at least an assertion from the SQL Server devs at...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Using Print, will it slow down procedure?

    ScottPletcher (9/14/2012)


    Lynn Pettis (9/14/2012)


    /****** Object: UserDefinedFunction [dbo].[DelimitedSplit8K] Script Date: 09/14/2012 09:43:51 ******/

    IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DelimitedSplit8K]') AND type in (N'FN',...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Searching the time data type

    Don't use it on AM starts with PM ends that are lower. 10:00 start, 13:00 end, would end up with the same problem you're trying to solve here. ...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Strange thing with "SET DATEFORMAT"

    SQL Kiwi (9/14/2012)


    GSquared (9/14/2012)


    Yep. I forgot it needs to have the hyphens removed.

    Yes. AFAIK, the 'yyyymmdd' format is always OK. I personally try to use a CONVERT...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Are the posted questions getting worse?

    Stefan Krzywicki (9/14/2012)


    Anyone know how to do this?

    Search time type between PM and AM

    I can't quite figure out a good way to google it or there's just nothing out there...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Need to get YYYYMM from date ?

    SELECT CONVERT(CHAR(6), GETDATE(), 112);

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: Searching the time data type

    If EndTime < StartTime, subtract 12 hours from both.

    DECLARE @Time1 TIME = '23:00', @Time2 TIME = '01:00';

    SELECT DATEADD(hour, -12, @Time1), DATEADD(hour, -12, @Time2);

    Edit: You'll have to subtract 12 hours from...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • RE: T-SQL Help Needed

    I have to agree that DUNS and email are (a) not "natural" keys, (b) very poor choices as primary keys (well, the DUNS numbers would be a good PK for...

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 15 posts - 811 through 825 (of 14,953 total)