Forum Replies Created

Viewing 15 posts - 7,351 through 7,365 (of 8,731 total)

  • RE: split column into multiple records based on substring fixed lenght

    I need you to post sample data and expected results, because I'm not sure that I understand the problem. To know how to do it, please read the article linked...

    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: Convert BigInt to seconds or milli-seconds or nano-seconds

    This might help you:

    http://en.wikipedia.org/wiki/Orders_of_magnitude_(time)

    1 second = 1,000 milliseconds

    1 second = 1,000,000 microseconds

    1 second = 1,000,000,000 nanoseconds

    You'll keep a bigint but you can use any order of magnitude you need.

    EDITED after...

    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: sql query to find the difference in values from previous month

    First of all, you should avoid using integers to store dates, even if they are just partial as month and year. You get in lots of trouble when calculating change...

    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: Is a Dynamic SQL solution possible in this case ?

    There's no need to use dynamic code. Here's one option and maybe someone could give a better one because I'm not so sure on its performance with big loads. It's...

    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: split column into multiple records based on substring fixed lenght

    All the "SELECT 1 UNION ALL" create 10 rows which I later use to create 100 rows with a CROSS JOIN in the next CTE.

    I'm using TOP 50 because you...

    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: Splitting column values iin multiple columns and assigning it to a row

    I hope that you're trying to normalize your data permanently because this will give you headaches.

    To split data you could use the DelimitedSplit8k. Check the article as it's really interesting.

    http://www.sqlservercentral.com/articles/Tally+Table/72993/

    WITH...

    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: split column into multiple records based on substring fixed lenght

    A Tally table (or in this case a cteTally) can come to the rescue.

    Check the following code and ask for anything that you don't understand.

    WITH E1(n) AS(

    SELECT 1 UNION ALL...

    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: SELECT question

    gary.morey (12/11/2013)


    SELECT *

    FROM Temp_BigTable

    WHERE SSN + PKT + FICE_NBR

    NOT IN (

    SELECT SSN + PKT + FICE_NBR

    FROM shi.raw33

    )

    I recommend you to read the following article NOT EXISTS vs NOT IN[/url]

    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: Finding the MIN and MAX date - How do I approach this?

    Would this help?

    WITH SampleData([EMPID],[EffectiveDate],[PrimaryRater], [PrimaryReviewer])

    AS

    ( --This is sample data

    SELECT '12345',convert(datetime,'10/10/2001'),'A12345', 'A67890' UNION ALL

    SELECT '12345','07/12/2013','A12345', 'B67890' UNION ALL

    SELECT '12345','08/18/2002','A12345', 'C67890' UNION ALL

    SELECT '12345','07/17/1966','A12345', 'D67890' UNION ALL

    SELECT '12345','01/01/1966','B12345', 'E67890'

    )

    --Solution starts here

    ,CTE...

    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: Finding the MIN and MAX date - How do I approach this?

    I had totally missed the point of the different EndDate for PrimaryRater B12345.

    Here's an option:

    ;WITH MyCTE([EMPID],[EffectiveDate],[PrimaryRater])

    AS

    ( --This is sample data

    SELECT '12345',convert(datetime,'10/10/2001'),'A12345' UNION ALL

    SELECT '12345','07/12/2013','A12345' UNION ALL

    SELECT '12345','08/18/2002','A12345' UNION ALL

    SELECT '12345','07/17/1966','A12345'...

    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: SQL syntax error

    Are you using SSRS to call tha procedure? SSRS might be changing your variables to the actual values in the query using the Join function. To correctly insert the 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: Finding the MIN and MAX date - How do I approach this?

    Just to be clear.

    Lowell used the following code as sample data:

    ;WITH MyCTE([EMPID],[EffectiveDate],[PrimaryRater])

    AS

    (

    SELECT '12345',convert(datetime,'10/10/2001'),'A12345' UNION ALL

    SELECT '12345','07/12/2013','A12345' UNION ALL

    SELECT '12345','08/18/2002','A12345' UNION ALL

    SELECT '12345','07/17/1966','A12345' UNION ALL

    SELECT '12345','01/01/1966','B12345'

    )

    And the following is...

    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: Finding the MIN and MAX date - How do I approach this?

    Lowell (12/10/2013)


    if you group by both EMPID and PrimaryRater, you don't get the "end Date" you were looking for according to your sample data, so im not sure if your...

    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: Multiple records returned from subquery

    Without DDL and sample data, I suppose that you would want a comma separated value for the 'Spec Comp' column. It's explained in this article: http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    This should do it, but...

    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: SQL syntax error

    The query doesn't seem to haev an error. However, there's something that intrigues me. You're using WHERE offc_code IN (@Offc) and seems that @Offc might be a comma-separated value.

    If it's...

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