Forum Replies Created

Viewing 15 posts - 961 through 975 (of 1,246 total)

  • RE: How to get running balance for missing week

    Ed Wagner (12/4/2015)


    Heh - I wonder which one's faster. 😉 To be safe, add this to the update:

    WITH (INDEX (0), TABLOCK)

    The INDEX(0) tells it to use the clustered index....

  • RE: How to get running balance for missing week

    here's a different option...

    IF OBJECT_ID('tempdb..#Dates', 'U') IS NOT NULL

    DROP TABLE #Dates;

    CREATE TABLE #Dates (

    WeekendDate DATE

    );

    INSERT #Dates (WeekendDate) VALUES

    ('11/01/2015'),

    ('11/08/2015'),

    ('11/15/2015'),

    ('11/22/2015'),

    ('11/29/2015');

    IF OBJECT_ID('tempdb..#Product', 'U') IS NOT NULL

    DROP TABLE #Product;

    CREATE TABLE #Product...

  • RE: How to get running balance for missing week

    try this...

    IF OBJECT_ID('tempdb..#Dates', 'U') IS NOT NULL

    DROP TABLE #Dates;

    CREATE TABLE #Dates (

    WeekendDate DATE

    );

    INSERT #Dates (WeekendDate) VALUES

    ('11/01/2015'),

    ('11/08/2015'),

    ('11/15/2015'),

    ('11/22/2015'),

    ('11/29/2015');

    IF OBJECT_ID('tempdb..#Product', 'U') IS NOT NULL

    DROP TABLE #Product;

    CREATE TABLE #Product (

    Product CHAR(1),

    Location...

  • RE: how to convert recursive CTE's into normal sql queries

    Sergiy (11/30/2015)


    Jason A. Long (11/30/2015)


    The other, less attractive, options are to use either a cursor or while loop.

    "Less attractive" is a questionable judgement. There were several tests here which proved...

  • RE: how to convert recursive CTE's into normal sql queries

    siddharthak024 (11/29/2015)


    My question is how to solve it, Please don't divert the issue. I have to use the non cte code in different places.

    As Jeff alluded, this is one of...

  • RE: how to convert recursive CTE's into normal sql queries

    siddharthak024 (11/25/2015)


    for example :

    with cte1(id) as

    {

    select query ..............

    union all

    select query.............

    join some query ................

    join cte1 on some query

    }

    how to replicate this logic into normal sql query

    I would really appreciate if...

  • RE: DateDiffs across multiple rows in a dataset

    If you're actually on SQL 2012, you should be able to get better performance by using the LEAD windowed function rather than a self join.

    Both versions produce the same...

  • RE: Subtract column with variable

    This should give you what you're looking for...

    -- your original test data --

    IF OBJECT_ID('tempdb..#t','U') IS NOT NULL

    DROP TABLE #t;

    CREATE TABLE #t (id INT NOT NULL ,col1 DECIMAL(18,2) NOT NULL );

    ...

  • RE: FK references only part of an existing PK

    A reprieve... Just had a conversation with the SVP in charge of the project...

    In the end we both agreed that the specific exception can change from contract version to contract...

  • RE: FK references only part of an existing PK

    drew.allen (11/19/2015)


    I actually tried to create a test on SQL 2012 (don't have SQL 2014 available) and when I tried to create the unique constraint, it failed saying that it...

  • RE: FK references only part of an existing PK

    RonKyle (11/19/2015)


    It violates Second Normal Form in that the foreign key is NOT dependent on the whole of the primary key. The fact that you had to specify IGNORE_DUP_KEY in...

  • RE: FK references only part of an existing PK

    drew.allen (11/19/2015)


    It violates Second Normal Form in that the foreign key is NOT dependent on the whole of the primary key. The fact that you had to specify IGNORE_DUP_KEY...

  • RE: FK references only part of an existing PK

    drew.allen (11/19/2015)


    Jason A. Long (11/19/2015)


    drew.allen (11/19/2015)


    The inclusion of the effective date in your key indicates that TableA is tracking some entity over time. If this is the case, then...

  • RE: FK references only part of an existing PK

    drew.allen (11/19/2015)


    The inclusion of the effective date in your key indicates that TableA is tracking some entity over time. If this is the case, then the entity will be...

  • RE: FK references only part of an existing PK

    Sean Lange (11/19/2015)


    RonKyle (11/19/2015)


    Is there no need or use for a table with the two fields as the primary key? On the face of it, it's more than an...

Viewing 15 posts - 961 through 975 (of 1,246 total)