Forum Replies Created

Viewing 15 posts - 54,571 through 54,585 (of 59,072 total)

  • RE: Arranging the data??

    SQLMAIN (10/16/2007)


    ISNULL(@SQL1+',','')+CHAR(10)

    Just curious - what does this line of code do and how?

    Noticed that if this is not there we just get one row but with this we get all...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Arranging the data??

    My pleasure... thank you for the feedback...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Arranging the data??

    Jason Selburg (10/16/2007)


    They do on my machine.

    Wait, do you mean Query Analyzer or Management Studio? They show in SSMS.

    I can definitely see that Steve and the guys need to...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Actual Reason to Use CLR

    Matt Miller (10/15/2007)


    ...which of course, would be true if you inserted ANYTHING in there instead of CLR. Try replacing CLR with: cursor's, UDF's, CTE's, T-SQL, triggers, jobs. As...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Actual Reason to Use CLR

    Possibly, David... in most cases that I've come across like that, the multiple procs were actually written (initially) to support the natural RBAR that occurs in GUI related code... such...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: concatenate multiple rows into a single row

    Thanks Phil... guess I'll just keep doing CPR (Cut, Paste, 'n' Replace) using Word until they fix the forum code... I just copy from QA into Word and replace all...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: delete and determine dups by datetime field

    Jay H (10/16/2007)


    I understand what you are saying.

    And I apologize for not being more clear.

    My primary key is a true primary key in another system. Instead of truncating the...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Arranging the data??

    They don't show if you copy and paste into Query Analyzer...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Nested Update Statement (NEW)

    Perfect... the rest of us can ignore you then.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Tracking changes made thru EM

    I can tell you haven't actually tried doing that... 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Arranging the data??

    Then, this should do it... not sure WHY you want to do this to perfectly good data, but it will do it...

    [font="Courier New"]--drop&nbsptable&nbspyourtable,&nbsp#Scratchpad

    --=====&nbspPresets

    &nbsp&nbsp&nbsp&nbspSET&nbspNOCOUNT&nbspON

    --=====&nbspCreate&nbspa&nbspsample&nbspdata&nbsptable.&nbspTHIS&nbspIS&nbspNOT&nbspPART&nbspOF&nbspTHE&nbspSOLUTION

    &nbspCREATE&nbspTABLE&nbspyourtable&nbsp(ID&nbspINT,&nbspName&nbspVARCHAR(10),Title&nbspVARCHAR(15))

    &nbspINSERT&nbspINTO&nbspyourtable&nbsp(ID,&nbspName,&nbspTitle)

    &nbspSELECT&nbsp'1','Seba','Developer'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'1','Joe','DBA'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'1','Steve','Developer'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'2','Deb','Developer'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'3','Dave','DBA'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'3','James','Developer'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'3','Venkat','DBA'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'3','Bob','Developer'

    --=====&nbspCopy&nbspthe&nbspdata&nbspinto&nbspa&nbsptemp&nbsptable&nbspwith&nbsproom&nbspfor&nbspan&nbspadditional&nbspcolumn

    &nbspSELECT&nbspID,&nbspName,&nbspTitle,&nbspCAST(0&nbspAS&nbspINT)&nbspAS&nbspSecondKey

    &nbsp&nbsp&nbspINTO&nbsp#Scratchpad

    &nbsp&nbsp&nbspFROM&nbspyourtable

    --=====&nbspThis&nbspindex&nbspis&nbspan&nbspabsolute&nbspmust&nbspto&nbspget&nbspthe&nbspgrouped&nbsprunning&nbspcount

    &nbsp&nbsp&nbsp&nbsp&nbsp--&nbspfor&nbspthe&nbspSecondKey&nbspcolumn&nbspto&nbspwork

    &nbspCREATE&nbspCLUSTERED&nbspINDEX&nbspComposite&nbspON&nbsp#ScratchPad&nbsp(ID,Title,Name)

    --=====&nbspDeclare&nbspsome&nbspobvious&nbspnamed&nbspvariables

    DECLARE&nbsp@PrevID&nbspINT

    &nbsp&nbsp&nbsp&nbspSET&nbsp@PrevID&nbsp=&nbsp0

    DECLARE&nbsp@SecondCount&nbspINT

    DECLARE&nbsp@SQL0&nbspVARCHAR(8000)

    DECLARE&nbsp@SQL1&nbspVARCHAR(8000)

    DECLARE&nbsp@SQL2&nbspVARCHAR(8000)

    --=====&nbspCreate&nbspthe&nbspgrouped&nbsprunning&nbspcount&nbspin&nbspthe&nbspSecondKey&nbspcolumn

    &nbspUPDATE&nbsp#ScratchPad

    &nbsp&nbsp&nbsp&nbspSET&nbsp@SecondCount&nbsp=&nbspSecondKey&nbsp=&nbspCASE&nbspWHEN&nbspID&nbsp=&nbsp@PrevID&nbspTHEN&nbsp@SecondCount+1&nbspELSE&nbsp1&nbspEND,

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp@PrevID&nbsp=&nbspID

    &nbsp&nbsp&nbspFROM&nbsp#ScratchPad&nbspWITH&nbsp(INDEX(Composite),TABLOCKX)

    --=====&nbspCreate&nbspthe&nbspnecessary&nbspdynamic&nbspSQL

    &nbspSELECT&nbsp@SQL0&nbsp=&nbsp'SELECT&nbspID,'

    &nbspSELECT&nbsp@SQL1&nbsp=&nbspISNULL(@SQL1+',','')+CHAR(10)&nbsp

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp+&nbsp'MAX(CASE&nbspWHEN&nbspSecondKey&nbsp=&nbsp'&nbsp+&nbspCAST(d.SecondKey&nbspAS&nbspVARCHAR(10))&nbsp+&nbsp'&nbsp'

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp+&nbsp'THEN&nbspName&nbsp&nbspELSE&nbsp''''&nbspEND)&nbspAS&nbspName'+&nbspCAST(d.SecondKey&nbspAS&nbspVARCHAR(10))&nbsp+&nbsp','+CHAR(10)

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp+&nbsp'MAX(CASE&nbspWHEN&nbspSecondKey&nbsp=&nbsp'&nbsp+&nbspCAST(d.SecondKey&nbspAS&nbspVARCHAR(10))&nbsp+&nbsp'&nbsp'

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp+&nbsp'THEN&nbspTitle&nbspELSE&nbsp''''&nbspEND)&nbspAS&nbspTitle'&nbsp+&nbspCAST(d.SecondKey&nbspAS&nbspVARCHAR(10))

    &nbsp&nbsp&nbspFROM&nbsp(SELECT&nbspDISTINCT&nbspSecondKey&nbspFROM&nbsp#ScratchPad)&nbspd

    &nbsp&nbspORDER&nbspBY&nbspd.SecondKey

    &nbspSELECT&nbsp@SQL2&nbsp=&nbspCHAR(10)+'FROM&nbsp#ScratchPad&nbspGROUP&nbspBY&nbspID'

    --=====&nbspExecute&nbspthe&nbspdynamic&nbspSQL

    --PRINT&nbsp@SQL0+@SQL1+@SQL2

    &nbsp&nbsp&nbspEXEC&nbsp(@SQL0+@SQL1+@SQL2)[/font]

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: delete and determine dups by datetime field

    You called one of your columns "PK"... if it were trully a primary key, it would not allow the dupes.

    Doesn't matter... the code I posted will find them as you...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: delete and determine dups by datetime field

    What you're calling a "PK" obviously isn't where this table is concerned or you wouldn't be able to insert the duplicate rows.

    However, to solve your problem, this will work... and,...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: Importing from CSV file

    Please see the following... leaves no quotes to cleanup...

    http://www.sqlservercentral.com/Forums/Topic296166-8-1.aspx#BM296961

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • RE: concatenate multiple rows into a single row

    Phil,

    What product are you using to format the code so nicely?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 15 posts - 54,571 through 54,585 (of 59,072 total)