Forum Replies Created

Viewing 14 posts - 61 through 74 (of 74 total)

  • RE: Order based on analyses on another table

    This solution will work, but will loop the update statement if there are any group of three (or more) teams with the same RANKING. I guess that is a rather...

  • RE: query question

    Jakke (2/12/2010)


    Hi Markus

    The "Quirky Update" did the trick 🙂

    I tested it against about 20000 records and the outcome was satisfying and quite fast as well.

    Next, i will put it on...

  • RE: Delete Records

    Hi John,

    It´s allways a good rule of thumb to use TOP 1 together with EXISTS, because it prevents the database engine from doing unneccesary work.

    I you write:

    select *

    from OneTable

    where EXISTS...

  • RE: Delete Records

    John Paul-702936 (2/11/2010)


    ...

    But .. The Script i am looking for is ..

    I want to delete the records from table2 which are in table1 ..mean matching all the columns

    So...

  • RE: query question

    Jakke (2/11/2010)


    Hi Markus,

    Thanks for the reply. 🙂

    I will certainly test your solution.

    You stated that it would work on not to big tables. Is a table with about 550000 records per...

  • RE: query question

    Hi again,

    just thought i should give the cursor solution aswell, since this is the more usual way to solve this kind of problem. It works fine if the table isn´t...

  • RE: query question

    Dear Jakke,

    this is actually a kind of "Running Total" problem, where you want one row to depend on the row before.

    Depending on the size of the tables, you can solve...

  • RE: Set Variable based on a SELECT

    Hi,

    since @mydate is of type DATETIME you get an implicit conversion of your neatly formatted string back to datetime.

    Declare @mydate as a CHAR(14), or what you find suitable, and everything...

  • RE: TSQL Help - Calculate Months

    SLLRDK (2/3/2010)


    ...

    INSERT INTO dbo.Bell_Invoice

    VALUES (1,'01/01/2010', '06/01/2010', 500)

    INSERT INTO dbo.Bell_Invoice

    VALUES (2,'11/23/2010', '06/01/2010', 100)

    ...

    select SUM(price) from dbo.Bell_Invoice

    WHEN StartDate <= @EndDate and EndDate >=@StartDate

    Which gives me results like:

    Price

    4750

    ...

    What I need is to be...

  • RE: WHILE LOOP vs. Recursive SQL

    Hi Tom,

    I would use a CTE to do the recursion. In your case you want to recurse both up and down in the hierarcy, so you would need two CTE:s...

  • RE: TSQL Help - Calculate Months

    Hi,

    I'm used to the dateformat YYYY-MM-DD, you can use your dateformat instead to fill the table...

    create table #a

    (

    id int IDENTITY(1,1),

    date datetime,

    price money

    )

    insert into #a VALUES ('2010-01-12', 10)

    insert into #a VALUES...

  • RE: [HELP] SUM & REPLACE

    Hi Knockyo,

    There is no good way to build dynamic queries the way you suggest. There is no way to dynamicaly change what columns to present in the result. You have...

  • RE: execute sp_executesql COUNT(*) Output

    If you need to do it by dynamic code you are boulding the parameters for sp_executesql incorrectly.

    Short example:

    DECLARE @SQLString nvarchar(500);

    DECLARE @ParmDefinition nvarchar(500);

    DECLARE @CountSQLQuery varchar(30);

    SET @SQLString = N'SELECT @result = COUNT(*)...

  • RE: group by two combining fields

    There are (of course) several ways to do this. One is to make sure that the lower node-number of the two always get in the first column. Then the grouping...

Viewing 14 posts - 61 through 74 (of 74 total)