Forum Replies Created

Viewing 15 posts - 3,451 through 3,465 (of 8,731 total)

  • RE: Datetime conversion

    J Livingston SQL (1/29/2016)


    Luis Cazares (1/29/2016)


    Maybe this:

    DECLARE @date varchar(10) = '14-Apr'

    SELECT CONVERT(datetime, '01 ' + RIGHT(@date,3) + ' ' + LEFT(@date,2), 6)

    Hi Luis......why not just use this instead??

    SELECT CONVERT(datetime, '20'+@date)...

    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: Trying to replace UNION

    Hugo Kornelis (1/29/2016)


    Luis Cazares (1/29/2016)


    Yet another option. However, I'm not sure which of the proposed versions would be the best option.

    SELECT Id,

    Amount,

    CashFlowDate

    FROM #Test

    CROSS APPLY( VALUES(Principal, 'Principal'), (Interest,...

    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 Query

    Wild idea:

    If you can't create adequate indexes on this table, try creating a new table with the same structure but proper indexes (probably clustering on TestDTTM) and load the data....

    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: CHECKing Values

    Iulian -207023 (1/29/2016)


    Jacob Wilkins (1/29/2016)


    Iulian -207023 (1/29/2016)


    OK , but why is the Id incremented and Id = 3 skipped ?

    Ta,

    Iulian

    From https://msdn.microsoft.com/en-us/library/ms186775.aspx, under "Remarks":

    For a given identity property 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: Datetime conversion

    Maybe this:

    DECLARE @date varchar(10) = '14-Apr'

    SELECT CONVERT(datetime, '01 ' + RIGHT(@date,3) + ' ' + LEFT(@date,2), 6)

    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?

    Koen Verbeeck (1/29/2016)


    Grant Fritchey (1/29/2016)


    BL0B_EATER (1/29/2016)


    Have you guys during your careers ever thought about doing something else in life.. as opposed to IT / SQL Server / Coding etc etc?

    Yeah,...

    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: check constraint not working as per the condition defined in sql server

    You don't have any default value. I'm guessing that you're trying to insert rows with new ids which would return a null value which is not equal to 1 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: Use ROW_NUMBER on a CTE result

    Exactly as twin.devil posted, maybe with less characters.

    DECLARE @start_date DATETIME;

    DECLARE @end_date DATETIME;

    SET@start_date = '2005-01-01';

    SET@end_date = DATEADD(yy, DATEDIFF(yy,0,getdate()) + 1, -1);

    WITH

    E(n) AS(

    SELECT 0 UNION ALL SELECT...

    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: Trying to replace UNION

    Yet another option. However, I'm not sure which of the proposed versions would be the best option.

    SELECT Id,

    Amount,

    CashFlowDate

    FROM #Test

    CROSS APPLY( VALUES(Principal, 'Principal'), (Interest, 'Interest')) x(Amount,AmtType)

    WHERE Amount >...

    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: TRY/CATCH blocks in SQL

    There are some objects that can be created inside a TRY/CATCH block, such as tables and indexes. Some objects, such as procedures should be the only thing in the batch....

    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: COALESCE

    tom.w.brannon (1/29/2016)


    I knew that coalesce would return the highest data type but never remember the ordering of that so I thought it was either going to be 10 or divide...

    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: Find Valid Date from String

    Orlando Colamatteo (1/28/2016)


    Ugh, thanks for the correction Ed. I am confident my C# code is correct but I was going from memory on the post as to the boundaries (was...

    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: Use ROW_NUMBER on a CTE result

    nhernandez 63958 (1/28/2016)


    Im trying to sort out the SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n) could you explain the nature of this method, please.

    Regards.

    Sure. This is called a Table Value Constructor. It's 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: Use ROW_NUMBER on a CTE result

    Two things to note:

    1. You're not using the correct value to order and your weeks might come in a wrong order.

    2. You shouldn't use recursive CTEs to generate rows. An...

    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: Compare Distinct from two queries

    powerofsound (1/28/2016)


    Thank you Luis!

    I love when I find out my code is doing something stupid, I learn something new every day I'm in SQL and you have opened my eyes...

    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 - 3,451 through 3,465 (of 8,731 total)