Forum Replies Created

Viewing 15 posts - 7,021 through 7,035 (of 8,731 total)

  • RE: Subtotal when vendorcode changed.

    Jeff Moden (2/5/2014)


    kishorefeb28 (2/4/2014)


    i found its not recommended so i have requested to handle it in the front end .

    You obviously didn't hear that from me. 😉 There's absolutely...

    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: Query Help : pull Store Procedure name from Command

    I'm pleasantly surprised, too. I wonder if this would stop people from improving working solutions.

    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: Query Help : pull Store Procedure name from Command

    Something like this?

    SELECT *,

    LEFT( REPLACE( REPLACE( COMMAND, 'exec ',''), 'execute ','') --Eliminate EXEC or EXECUTE

    , PATINDEX( '%[ (]%', REPLACE( REPLACE( COMMAND, 'exec ',''), 'execute ','')) - 1) --Find the...

    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: I need to deduplicate a 800 million row table (100 million rows have duplicates)

    With 800M rows, I would use a bulk export/import for this. I see 2 options:

    Use bcp to export query with a SELECT DISTINCT (or GROUP BY all columns), truncate the...

    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: Sending a Variable Number of Elements in a Parameter

    I would like to thank Alex for this article. I know that a lot of people can get an idea of the options listed in here.

    I agree, however, that it...

    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: Window function on different date ranges

    dwain.c (2/5/2014)


    Luis has provided you a perfectly good solution to your question.

    I managed to get into your head. I hope you won't have nightmares :hehe:

    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: How to write a Query to get related result

    I agree that your expected results are wrong because you have an enddate greater than the startdate and that will generate a problem in the next row (rows 3 &...

    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: Strange Conversion Issue from varchar to Int

    Depending on what you need, you might want to take a look at TRY_CAST() or TRY_CONVERT()

    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: Hierarchical order by TSQL

    I might not be realizing the problem that Sean is talking about, but here's an example on how to do it. Be sure to understand what's going on before using...

    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: T-SQL Pivot Question

    And this is why I really love cross-tabs. Pivot becomes completely annoying with multiple columns or calculations being pivoted. I struggled to get right the pivot approach.

    Again, any comments are...

    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: T-SQL Pivot Question

    It seems that I get very similar results with pivot and cross tabs. The parallelism is created with the pre-aggregation because the normal pivot and cross tabs won't use it....

    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: using a user defined function in a view - need help

    I have nothing to test, but a single call to the function might work better.

    SELECT t1.[Text] ...

    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: last 6 months data

    Have you read about NULLIF?

    You could use something like this:

    CASE WHEN MAX(PutchaseAmount) = -1 /*AND MIN( PutchaseAmount) = -1*/ --Uncomment if you have other negative values

    THEN -1

    ELSE ISNULL(AVG(NULLIF(PutchaseAmount ,-1)), 0)...

    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: last 6 months data

    Yes, converting to float won't be useful because the aggregate will continue to consider it. You need to convert it to a null value to prevent that. Or you need...

    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: Time between range

    Here's a possible solution, it's not pretty but it's better than my first version full of functions on the columns.

    DECLARE @Timetime = '03:30:00';

    WITH Shift_table(Shiftno, starttime, endtime) AS(

    SELECT 1, CAST( '06:00:00'...

    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 - 7,021 through 7,035 (of 8,731 total)