Forum Replies Created

Viewing 15 posts - 6,631 through 6,645 (of 8,731 total)

  • RE: group columns to one row

    I'm grumpy today, but something made me help you more. Usually, on a day like this, I would have asked you to post DDL and sample data in a consumable...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SQL Transpose / Pivot - Help

    I would unpivot[/url] the source table, join it with the metadata table, use cross tabs[/url] to obtain the desired result and run away from that horrible design.

    That destination table looks...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: group columns to one row

    demin99 (4/1/2014)


    I tried to use Stuff and XMLpath but it is not giving me distinct results.

    Have you tried nesting them?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Are the posted questions getting worse?

    SQLRNNR (4/1/2014)


    Ed Wagner (4/1/2014)


    Lynn Pettis (4/1/2014)


    jasona.work (4/1/2014)


    ...

    OK, old man rant off (crap, 44 is just 3.5 weeks away!)

    You're not old!

    Personally, I really hope you're not old at 44. 😉

    Personally I...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help with CTE please.

    You were really close to the solution.

    WITH CTE1

    as

    (

    SELECT r.GradeId,

    r.DateofMfg,

    ROW_NUMBER() OVER (order by r.DateofMfg)

    - ROW_NUMBER() OVER (Partition by r.GradeId order by r.DateofMfg) as GroupID

    FROM @t r...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SP

    I can't give more advice on this, unless you post more details. I don't know what kind of modifications you did or what are the change policies on your company.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Sub Query and Left Joins to isolate data for Merge and Insert

    the.roof (3/31/2014)


    Luis Cazares (3/27/2014)


    The subquery looks fine, you're filtering using JOINs. You could change them to IN or EXISTS and you might have a slight performance gain, but it...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Sorting based on last 12 months.

    marsidbomba (3/31/2014)


    What if the data is March 2014, February 2014,January 2014, December 2013, November 2013 ... April 2013. Would you be able to sort that?

    Only if you cast them as...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Dates in different languages

    You could use the syslanguages view along with the DelimitedSplit8K[/url] and Crosstabs[/url].

    SELECT

    MAX( CASE WHEN name = 'us_english' THEN s.Item END ) English

    ,MAX( CASE WHEN name = 'Deutsch' THEN s.Item...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: SP

    Use a test environment.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Sorting based on last 12 months.

    You need to have the complete date value to order the months correctly or you could have another value to order by.

    Examples:

    DECLARE @Date date;

    SET @Date = '20140405'

    SELECT LEFT( DATENAME( MM,...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: rewrite cursor to set based

    The code is still there. It's just located at the end instead of the beginning.

    I'm glad that you're helping. I'm just trying to pay it forward. 😉

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help With WHERE Statement

    Eirikur Eiriksson (3/31/2014)


    Luis Cazares (3/31/2014)


    Here are 2 other options.

    WITH Contacts AS(

    SELECT INS.INSPNO, CNT.FIRSTNAME, CNT.LASTNAME, CNT.CAPACITY,

    ROW_NUMBER() OVER( PARTITION BY INS.INSPNO ORDER BY CASE WHEN Capacity = 'Contractor' THEN -1 ELSE INS.INSPNO...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: Help With WHERE Statement

    Here are 2 other options.

    WITH Contacts AS(

    SELECT INS.INSPNO, CNT.FIRSTNAME, CNT.LASTNAME, CNT.CAPACITY,

    ROW_NUMBER() OVER( PARTITION BY INS.INSPNO ORDER BY CASE WHEN Capacity = 'Contractor' THEN -1 ELSE INS.INSPNO END DESC) rn

    FROM @inspection...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • RE: rewrite cursor to set based

    It seems almost fine, but it's weird. You're not summing up the values. I added the SUM() and converted it to a iTVF. You need to test it as well...

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 15 posts - 6,631 through 6,645 (of 8,731 total)