Forum Replies Created

Viewing 15 posts - 451 through 465 (of 1,228 total)

  • RE: Should I use a nested subquery?

    thomasrichardson2000 (10/11/2012)


    Didn't work just pulled back the same result set, I need the query to be able to search the vehicle table for all the modelid on the fleet at...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: please help with query

    -- sample data

    ;WITH

    MySample (ID, notes, account1, account2, account3, account4, account5) AS (

    SELECT 1, 'notes', 1, 0, 1, 0, 1 UNION ALL

    SELECT 2, 'notes', 0, 1, 0, 1, 0...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Function or Join

    Dhirju (10/11/2012)


    which is better for performance wise,

    function or join?

    thanks

    An inline table-valued function can perform equally as well as a join to tables. If the function has BEGIN/END in it,...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Should I use a nested subquery?

    Do you get different results with/without the DISTINCT?

    Here's a reformatted copy of the query. I've added table aliases to make it a little more readable and changed the order of...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Checking for a string until if finds, then insert that into new table

    Skanda (10/11/2012)


    Am using below query, but it is not working.

    select record_id,

    if Col1= 'Student'

    Begin

    Insert record_id, Student as Stud into new_table

    end

    else if Col2 = 'Student'

    Begin

    Insert record_id, Student as Stud into new_table

    end

    else...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Update a Record Using a Trigger with SELECT Statement

    What's the UPDATE statement you are using, and is there any reason why it can't include VLoadnoteCarr?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Help on Performance issue on Recursive CTE

    Can you make ParentID a non-unique clustered index? It will almost certainly improve performance. Might as well remove the TOP 100 PERCENT too, it's only pretending to do something.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Delete existing records, after inserting new record

    Skanda (10/11/2012)


    hi,

    as per my requeirement when ever i insert new record, existing record should be deleted.

    What denotes "existing record"? How do you identify it?

    Why don't you use UPDATE instead of...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Delete existing records, after inserting new record

    Skanda (10/11/2012)


    Hi

    i want to delete existing records from sql table, after inserting new record.

    am using below code...

    CREATE trigger Del_records on Active_Table

    AFTER insert

    as

    delete from Active_Table

    but it is deleting all records

    plz...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: OPTION (RECOMPILE, QUERYTRACEON 8649)

    aadharjoshi (10/11/2012)


    Thank you all..!

    I appreciate your help.. Most probably i can remove in clause and use inner join..

    Folks here would be happy to help you tune your query. Can you...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: OPTION (RECOMPILE, QUERYTRACEON 8649)

    Jason-299789 (10/11/2012)


    ...as you're getting rid of a potentially expensive IN statement and using an Inner join from a CTE, the variable is no longer on the join and in the...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: SQL Server Linked Server Distributed Query with Parameter vs Literal

    The filter is being applied locally. You could use EXEC with dynamic SQL as Chandan suggests; I'd personally use OPENQUERY, which will also require your statement to be constructed as...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: OPTION (RECOMPILE, QUERYTRACEON 8649)

    aadharjoshi (10/10/2012)


    What OPTION (RECOMPILE, QUERYTRACEON 8649) will do when i add it to query?

    eg..

    SELECT COUNT(T.CompanyID),

    COUNT(UserDataID)

    FROM...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: OPTION (RECOMPILE, QUERYTRACEON 8649)

    aadharjoshi (10/10/2012)


    What OPTION (RECOMPILE, QUERYTRACEON 8649) will do when i add it to query?

    ...

    RECOMPILE

    QUERYTRACEON 8649

    If you suspect you are experiencing performance problems with one or more of your queries,...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Help on Performance issue on Recursive CTE

    mister.magoo (10/10/2012)


    Hi there, I would like to offer you my own twist on this using the "identity hack".

    The outline of the logic is to replace the recusive cte with a...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

Viewing 15 posts - 451 through 465 (of 1,228 total)