Forum Replies Created

Viewing 15 posts - 4,426 through 4,440 (of 8,731 total)

  • RE: Rounding to the nearest quarter hour ?

    An idea:

    SELECT DATEDIFF(second,Information.[Start Time],Information.[End Time]) / 60.00 / 60.00,

    CEILING( DATEDIFF(second,Information.[Start Time],Information.[End Time])*4 / 60.00 / 60.00) / 4 AS Rounded_Hours,

    ROUND( DATEDIFF(second,Information.[Start Time],Information.[End...

    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: Rounding to the nearest quarter hour ?

    Do you always want to round up? Or why isn't the first result 1.25?

    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: While loop to replace text - how to re-write to use set processing

    You're welcome, feel free to ask any questions that you have.

    I also created an initial version that lacked versatility and replaced only the first order number. It was like this:...

    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: Merge column vales into rows

    Then just follow the process described in here: http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    WITH cteOrders AS(

    SELECT DISTINCT OrderID

    FROM #Status

    )

    SELECT OrderID,

    STUFF((SELECT ',' + Status

    ...

    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: Data Shuffle Question

    Are you missing information? Where do you get the persons that will be assigned? Are those the reviewers?

    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: Merge column vales into rows

    Why are you doing that? It will only make your querying more painful. You shouldn't store comma-delimited values in the db.

    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: While loop to replace text - how to re-write to use set processing

    Here's a possible option. Be sure to test what it does and understand it.

    It basically splits the strings to find the different digit portions by using the PatternSplitCM which can...

    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: Bad Behavior Creating Stored Procedure

    As you might have noticed, BEGIN and END won't define the begin and end of a stored procedure.

    A stored procedure must be the only statement in the batch, so anything...

    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: charindex/substring to replace varying amounts of '/'

    A slightly different version of Eirikur's code. This is just to give you more ideas on the different possibilities to solve your problem.

    DECLARE @sourcedata TABLE(STR_DATA VARCHAR(100) NOT NULL);

    INSERT INTO @sourcedata(STR_DATA)

    VALUES

    ...

    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: Pull top 3 max values for each account

    Sean Lange (8/11/2015)


    Luis Cazares (8/11/2015)


    You can use a code like this:

    WITH RowNums AS(

    SELECT *, ROW_NUMBER() OVER(PARTITION BY account ORDER BY date DESC) rn

    ...

    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: Pull top 3 max values for each account

    You can use a code like this:

    WITH RowNums AS(

    SELECT *, ROW_NUMBER() OVER(PARTITION BY account ORDER BY date DESC) rn

    FROM SomeTable

    )

    SELECT *

    FROM RowNums

    WHERE...

    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: Are the posted questions getting worse?

    Alvin Ramard (8/11/2015)


    Ed Wagner (8/11/2015)


    Sean Lange (8/11/2015)


    Ed Wagner (8/11/2015)


    The silver spoons need to be ordered again. Better get at least a case.

    Here's a quote I don't think I've every...

    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: Help with SQL Query

    Normally, Grant's remark should be on point, but here you need to change the column. I added a few other improvements that you might want to implement. Avoid 3 part...

    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: max not giving the latest one

    If this doesn't give a full solution, it might give an idea.

    with base as (

    select

    *,

    rn = row_number() over (partition by left(kms_quoteorder,charindex('/',kms_quoteorder +...

    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: Help Need in join

    This article explains the FOR XML PATH approach.

    http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    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 - 4,426 through 4,440 (of 8,731 total)