Forum Replies Created

Viewing 15 posts - 4,651 through 4,665 (of 14,953 total)

  • RE: Expand this to multiple concurrent hierarchies and effective date sensitive?

    Turn the adjacency hierarchy into a standard many-to-many (joining the primary table back to itself), with a date-effective range in the join table.

    When you build the CTE, you just have...

    - 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: Displaying Sorted Hierarchies (SQL Spackle)

    Jeff Moden (3/10/2011)


    GSquared (3/10/2011)


    I've used a variation on this solution for sorting before, and found that it works best if you pad numerical values with leading zeroes to a fixed...

    - 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: Displaying Sorted Hierarchies (SQL Spackle)

    Jeff Moden (3/10/2011)


    GSquared (3/10/2011)


    I've got a two-step script that can generate a nested sets "path" from an adjacency hierarchy, turning it into a nested sets hierarchy, using Cross Apply 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: Displaying Sorted Hierarchies (SQL Spackle)

    Jeff Moden (3/10/2011)


    Wesley Brown (3/10/2011)


    I prefer to use a two column approach to build a tree instead of the single column style that you have to split, it doesn't scale...

    - 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: database mail trigger on insert

    You need Alter Object permissions to truncate, because of what it does to Identity columns and all that.

    You might be better off skipping that step entirely. You can include...

    - 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 it possible in any DBMS or in RDBMS?

    I did this in SQL 2008. Used your table create and populate script, then:

    ;with Prizes as

    (select *, ROW_NUMBER() over (partition by ProductName, Unit order by Value desc) as Row

    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: String search and replace it with single letter

    Yes. You just need to change the Like statement to include the Letter column as many times as you're looking for, and then change the Replace statement the same...

    - 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: If else statement having errors

    You'd have to rework the way you're calling the data in order to get that to work.

    - 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: DR solution..Pls respond

    alen teplitsky (3/9/2011)


    GSquared (3/9/2011)


    alen teplitsky (3/9/2011)


    the pro's of vmware is that you ship the entire instance to DR and just mount it on your DR vmware host and change the...

    - 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: Displaying Sorted Hierarchies (SQL Spackle)

    I've used a variation on this solution for sorting before, and found that it works best if you pad numerical values with leading zeroes to a fixed length, before sorting...

    - 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: Regain disk space after cleaning up tables and indexes

    Removing data from a database won't make the files shrink. You have to actually tell it to shrink them to get that to happen.

    Keep in mind that shrinking 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: String search and replace it with single letter

    Since you already have the letters (in your Numbers table), you don't need the CTE at all.

    Change:

    WHILE @@rowcount > 0

    with Letters(Letter)

    ...

    - 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: Breaking data into Subsets and Calculating Mean, Median, Mode

    Ghanta (3/9/2011)


    Thanks GSquared ... I had used http://www.sqlservercentral.com/scripts/Miscellaneous/31775/ but yours is even better as it takes care of median for even sets correctly. Thanks!

    they want mode as well as subsets...

    - 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: String search and replace it with single letter

    I would need to see the actual code you're using before I could tell you what to do to fix a syntax error.

    - 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 an IN Operator as a Parameter in a Stored Procedure

    There are advantages over a delimited list beyond just avoiding having to first concatenate the list together and then shred it back apart again.

    First, the table variable has a defined...

    - 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 - 4,651 through 4,665 (of 14,953 total)