Forum Replies Created

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

  • 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,...

  • 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....

  • 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...

  • RE: Datetime conversion

    Maybe this:

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

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

  • 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,...

  • 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...

  • 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...

  • 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 >...

  • 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....

  • 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...

  • 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...

  • 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...

  • 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...

  • 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...

  • RE: Compare Distinct from two queries

    There's an issue when using NOT IN and the inner query returns a NULL value. In that case, it won't return any rows. You can correct that adding an additional...

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