Forum Replies Created

Viewing 15 posts - 5,116 through 5,130 (of 14,953 total)

  • RE: To get the Max value from one column with case statement without using any aggregate functions

    This kind of weird requirement is usually schoolwork. Is it this time?

    - 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: newbie - Needs help with a delete query that joins 3 tables

    Well, since the first statement deletes from a, and the second and third depend on the data still being in a for their joins to work, I'd be surprised if...

    - 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: newbie - Needs help with a delete query that joins 3 tables

    Delete only works on one table at a time (Select is really the only one that can work with multiple target tables).

    What you'll need to do is delete from "a",...

    - 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: NULL value in Default constraints

    Almost certainly not. Try some tests on your hardware, see if it has any impact at all. I doubt it will.

    - 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: extract the data most closed to the date around date

    skt5000 (2/4/2011)


    Will that still work if there is more than one MRN?

    Jim

    It'll depend on the exact need of the query.

    If you need one per MRN, I'd probably do it through...

    - 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?

    Tom.Thomson (2/4/2011)


    GSquared (2/4/2011)


    If the next ice age kicks into gear in a year or two (my personal expectation based on nothing but how cool I think it would be; you...

    - 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: NULL value in Default constraints

    I guess it follows the "explicit is better than implicit" rule of thumb, but otherwise, there's no benefit I can think of to it.

    - 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: extract the data most closed to the date around date

    Alternately:

    DECLARE @ADT TABLE (MRN int,ECDNo int,AdmDt date,AdmTm Time,DischDt date)

    INSERT INTO @ADT

    SELECT 6232201, 100060525,'2010-11-22','12:52','2010-11-24' UNION

    SELECT 6232201, 100066361,'2010-12-06','13:03','2010-12-09' UNION

    SELECT 6232201, 100068059,'2010-12-09','12:22','2010-12-12'

    DECLARE @OBlog TABLE(MRN int, DelDate date,DelTime time)

    INSERT @OBlog

    SELECT 6232201,...

    - 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: Avoid a record that has first character as number in a column

    I'd turn this:

    where firstname LIKE '[!-/:-ÿ]%'

    into:

    where firstname LIKE '[^0-9]%'

    The carat (up-arrow) means "excluding" in there. It's more clear that the exact thing you want to do is exclude 0-9,...

    - 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: Avoid a record that has first character as number in a column

    This should give you what you need more efficiently that the current code:

    where firstname NOT LIKE '["#.%$[-]_()*0-9]%'

    The square-brackets give the Like operator a range of characters to operate on.

    What you...

    - 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: Performance Best Practices

    Honestly, there are two ways to deal with this.

    First, is review all database code yourself and make sure it's properly tuned, before it goes into production.

    Second, is monitor the database...

    - 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: Total time in a day

    First, select all clock-ins, with their corresponding clock-outs.

    I usually would do that something like this:

    select PersonID, MyDateTimeColumn as ClockIn,

    (select min(MyDateTimeColumn)

    from dbo.MyTable as MT2

    where MT2.PersonID...

    - 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: Constraint help

    Is it possible that they are disabled?

    Usually, dropping and re-creating (with check) is the best way to get them trusted.

    - 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: Is length of a Varchar a concern

    With the way that varchar data is stored, there really isn't any significant different between those two, in terms of storage, performance, et al.

    There is a difference between char and...

    - 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?

    Brandie Tarvin (2/4/2011)


    GSquared (2/4/2011)


    If the next ice age kicks into gear in a year or two (my personal expectation based on nothing but how cool I think it would...

    - 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 - 5,116 through 5,130 (of 14,953 total)