Forum Replies Created

Viewing 15 posts - 54,601 through 54,615 (of 59,098 total)

  • 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)

  • RE: Arranging the data??

    Just curious... why do you have the same ID for 3 different people?

    --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: I need help with updating multiple columns in a table

    Whew! Yeah, I knew the *= and =* outer joins would sometimes cough up bad results... they actually started going bad in SQL Server 7... I'm surprised they didn't...

    --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: Unstring text field?

    Lowell (10/15/2007)


    the DBA toolkit here on SSC has regular expressions as extended stored procedures for SQL2K; i use it all the time.

    Thanks for the tip, Lowell...

    --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: NEWID() structure

    Correct... and it's not a good idea to base things on the system clock... SQL Server only has a resolution of 3.3 milliseconds... a lot can happen in 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)

Viewing 15 posts - 54,601 through 54,615 (of 59,098 total)