Forum Replies Created

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

  • RE: Table matching (tricky perhaps)

    CASE WHEN a.col1 = b.col1 THEN 1 ELSE 0 END

    + CASE WHEN a.col2 = b.col2 THEN 1 ELSE 0 END

    + CASE WHEN a.col3 = b.col3 THEN 1 ELSE 0 END

    +...

    --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: Combining Query Results

    Sure...

    [font="Courier New"]--=====&nbspThis&nbspis&nbspjust&nbspto&nbspbuild&nbspsome&nbspsample&nbspdata&nbspand&nbspis&nbspNOT&nbsppart&nbspof&nbspthe&nbspsolution

    DECLARE&nbsp@yourtable&nbspTABLE&nbsp(FromUser&nbspVARCHAR(10),&nbspToUser&nbspVARCHAR(10))

    &nbspINSERT&nbspINTO&nbsp@yourtable&nbsp(FromUser,&nbspToUser)

    &nbspSELECT&nbsp'user1','user2'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'user2','user1'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'user1','user2'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'user1','user3'&nbspUNION&nbspALL

    &nbspSELECT&nbsp'user3','user1'

    --=====&nbspThis&nbspis&nbspthe&nbspsolution

    &nbspSELECT&nbspd.FromUser,&nbspd.ToUser,&nbspCOUNT(*)&nbspAS&nbspTimeConnected

    &nbsp&nbsp&nbspFROM&nbsp(--====&nbspDerived&nbsptable&nbspswaps&nbspusers&nbspwhen&nbspneeded

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSELECT&nbspFromUser,&nbspToUser

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFROM&nbsp@yourtable

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWHERE&nbspFromUser&nbsp<&nbspToUser

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspUNION&nbspALL

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSELECT&nbspToUser&nbspAS&nbspFromUser,

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFromUser&nbspAS&nbspToUser

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFROM&nbsp@yourtable

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspWHERE&nbspToUser&nbsp<=&nbspFromUser

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp)&nbspd

    &nbsp&nbspGROUP&nbspBY&nbspd.FromUser,&nbspd.ToUser[/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: SUBSTR - SUBSTRING function extension

    SQL Server has a LEFT and a RIGHT... no need to build a special function to do it as bad as Oracle 😉

    --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: is this a good trigger?

    Sure... A thing called "Books Online" should become your best friend. One way of getting to it is to open Query Analyzer, click on the [Help] button, and select...

    --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: SQL Code

    You bet... 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: Bulk Insert

    Could be any of a dozen different problems... you need to post the code you're using and the CREATE statement for the table you are importing 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

    Grant, I'm with you... I see no compelling reason for CLR's. My opinion, for the most part, for them being there is the same as DTS and Cursors... they...

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

    The easiest way to split limited (up to 4 parts) period-delimited text of this nature is to use PARSENAME. Look it up in Books Online for a full explanation.

    Here's...

    --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: query statistics

    This is very nearly a duplicate post...

    http://www.sqlservercentral.com/Forums/Topic410280-65-1.aspx

    The only thing that means anything about performance for all the timers you have here is this...

    Number of TDS packets received 28569 28569

    Number of...

    --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: Execution plan

    That information is available in Books Online ("Transact-SQL Help" under Help button in Query Analyzer). Lookup "Execution Plan pane" in the index...

    --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: statistics time on

    If you're asking how long we think it should take for you to process the 1.7 million rows that your are... we have no clue because we don't know what...

    --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: SQL Code

    SELECT *

    FROM yourtable

    WHERE Address1 LIKE '[0-9]%'

    --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 Temp Table within a Cursor

    You could have also used TRUNCATE table which resets the ID column back to 1.

    But, even that doesn't "Fix" it... why are you using a cursor? Perhaps if 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: NEWID() structure

    NEWID() won't guarantee it... it's only guaranteed at the full 32 characters.

    What's wrong with this?

    SELECT CAST(CAST(0x0013020061675035 AS BIGINT)+1 AS VARBINARY)

    If you find the largest item in the column, just add...

    --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: Determine field names of stored proc return

    I only see the column names being returned... no data types...

    --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,072 total)