Forum Replies Created

Viewing 15 posts - 1,951 through 1,965 (of 8,731 total)

  • RE: CASE WITH EXISTS

    Sean Lange (10/31/2016)


    Luis Cazares (10/31/2016)

    Although, if the row count is really low on that table, here's an alternative.

    SELECT TOP ISNULL( MAX(CONCAT(i.BatchId,+'_'+ i.Company+'_',ltrim(rtrim(i.[Accounting Period]))+'_nondlo.saf')), 'None')

    FROM [Havebury].[RepairInvoice].[RepairInvoiceNONDLO] i;

    Thank Luis. I thought...

    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: Assigning a record count to a variable for comparison purposes

    There's no need for dynamic code. You just need to query a system view with a parameter.

    SELECT SUM (row_count)

    FROM sys.dm_db_partition_stats

    WHERE object_id=OBJECT_ID(?)

    AND index_id IN( 0, 1);

    This will be...

    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: CASE WITH EXISTS

    I believe that Sean means something like this:

    SELECT TOP 1 *

    FROM(

    SELECT TOP 1

    CONCAT(i.BatchId,+'_'+ i.Company+'_',ltrim(rtrim(i.[Accounting Period]))+'_nondlo.saf')

    , 1

    ...

    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: CASE WITH EXISTS

    Why don't you simply use

    SELECT CONCAT(i.BatchId,+'_'+ i.Company+'_',ltrim(rtrim(i.[Accounting Period]))+'_nondlo.saf')

    FROM [Havebury].[RepairInvoice].[RepairInvoiceNONDLO] i

    Instead of using subqueries and CASE clauses?

    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: Today's Random Word!

    Manic Star (10/31/2016)


    Ed Wagner (10/31/2016)


    Grumpy DBA (10/31/2016)


    djj (10/31/2016)


    Remington

    Shaver

    Beard

    Lady

    Marmalade

    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: What random trash is in your drawer?

    Steven.Grzybowski (9/27/2016)


    Eric M Russell (9/26/2016)


    Steven.Grzybowski (9/26/2016)


    A locked box.

    Inside that locked box is medication. Lots and lots of medication. My regularly prescribed daily meds, every OTC NSAID...

    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: SSIS and column restrictions

    Lynn Pettis (10/28/2016)


    Luis Cazares (10/28/2016)


    Why aren't you using flat files to transfer the data so you don't have to deal with additional storage needed by spreadsheets?

    Also, depending on the driver,...

    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: SSIS and column restrictions

    Why aren't you using flat files to transfer the data so you don't have to deal with additional storage needed by spreadsheets?

    Also, depending on the driver, you can get a...

    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: Recursive CTE performance improvement

    I´m not sure what to say. You should know the deal by now. We need DDL, sample data and expected results.

    The query that I posted gives the exact same result...

    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: Recursive CTE performance improvement

    sqlfriends (10/27/2016)


    I have a table valued function to count student truant days in any passed 30 days that met threshold of 7 days and return the earliest passed threshold date.

    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: why my query returns scientific notation for a varchar field?

    halifaxdal (10/27/2016)


    found a simple solution: select str(column)

    PS. the above query is producing wrong result, changing 1234565789 to 123456000, I'm keep searching for a simple solution now

    That's because once the value...

    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: Update Query Help in T-SQL

    Include the columns in the derived table by using MIN or MAX on them.

    Then use a CASE clause to update only when the row_count = 1.

    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: DTA - want to delete dta indexes

    I think you're confusing the indexes created using DTA, with the indexes created during the DTA analysis but usually removed after the process completes. These later indexes are hypothetical and...

    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: Can anyone help optimize runtime on a dimension creating query?

    Thom A (10/27/2016)


    Luis Cazares (10/27/2016)


    This runs several times faster. I just can't understand why the FORMAT function is so slow.

    I really wish it wasn't. It's a lazy man's dream. :hehe:

    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: Can anyone help optimize runtime on a dimension creating query?

    This runs several times faster. I just can't understand why the FORMAT function is so slow.

    The TOP also prevents generating all the row numbers which gives an additional boost.

    DECLARE @Hour_Quarter_ID...

    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 - 1,951 through 1,965 (of 8,731 total)