Forum Replies Created

Viewing 15 posts - 4,351 through 4,365 (of 7,597 total)

  • RE: Query can be improved?

    And prefix every column in the query with a table alias. Remember, we have no idea what columns are in what tables.

    Which table is "ID" in?

    Which table is "NO_OF_PIN"...

  • RE: Assign Variables

    mceventphoto (3/23/2016)


    In reviewing the code I posted, I figured out that the second cursor is not needed. I simply replaced the portion of the where clause.

    Where b.ITEMCODE = @itemCode

    with

    Where...

  • RE: Assign Variables

    Sure, you can do it, but if you post the code it's extremely likely we here can re-work the entire method being used and make it much better.

    create table #values...

  • RE: Query help

    The year, the 3-digit number and the incrementing number should all be stored as separate columns. You then use a computed column to construct the rptnum column. That...

  • RE: Insert Stored Procedure Results Into New Table Without Using OPENQUERY

    Excellent article! My only additional suggestion would be to put your code in the master db, and start the proc name with sp_, so that the code can easily...

  • RE: SQL

    edward_hall76 (3/21/2016)


    DBA or developer.

    Hmm, overall vastly different qs, but if they are supposed to have experience, here's one q I love to ask ... but give them some time to...

  • RE: Query performance help (ready-to-use sample data included)

    Don't see anything better at a relatively quick look, although I would get rid of the double negative logic:

    SELECT *

    FROM #OrderDetails OD

    WHERE OD.ActionCode = 'V' OR...

  • RE: Optimize SP

    Sergiy (3/17/2016)


    TheSQLGuru (3/17/2016)


    1) using a temp table (NOT table variable!!)

    Not sure if there is much of a difference here.

    Scoping - yes, quite different.

    Can you name anything else?

    You can...

  • RE: DATEADD shortcut

    Phil Parkin (3/17/2016)


    ScottPletcher (3/17/2016)


    Phil Parkin (3/16/2016)


    DATETIME is stored internally in SQL Server as the number of days since 1/1/1900 (the integer part) plus (I think) a decimal part representing the...

  • RE: DATEADD shortcut

    Phil Parkin (3/16/2016)


    DATETIME is stored internally in SQL Server as the number of days since 1/1/1900 (the integer part) plus (I think) a decimal part representing the number of 300ths...

  • RE: 0 is equal to zero length string. Can someone explain how this can be?

    Jeff Moden (3/16/2016)


    Sergiy (3/16/2016)


    Jeff Moden (3/16/2016)


    Lynn Pettis (8/6/2012)


    An empty string is not null, it is a known value (empty).

    I strongly agree. NULL is not NOTHING. NOTHING...

  • RE: Dropping primary key improves performance

    You need to review the indexes from scratch. That is, analyze SQL's index usage stats, missing index stats and index operational stats. The longer time period you have...

  • RE: Linked Server from Test to Production

    You can reduce the effect on production by using "WITH (NOLOCK)" on the reads, unless you need an absolutely accurate copy of the data in test. If so, you'd...

  • RE: Count of records in all tables, specify DB

    I suggest creating the proc in the master db and marking it as a "system" proc. It will then work within the context of the current db, whatever that...

  • RE: subtracting a case statement result from a Convert(char(8) result

    Maybe?:

    SELECT CONVERT(varchar(8), DATEADD(SECOND, DATEDIFF(SECOND, ISNULL(QueueDate, StartDate), EndDate), 0), 8)

Viewing 15 posts - 4,351 through 4,365 (of 7,597 total)