Forum Replies Created

Viewing 15 posts - 1,936 through 1,950 (of 2,171 total)

  • RE: How many more Mondays until I retire?

    Yes, I did benchmark your code Razvan. Did you try your test-code yourself?

    Running your test-code above gives 763 milliseconds for my function and 1,563 milliseconds for your function.

    Mine is faster and...

  • RE: How many more Mondays until I retire?

    The best way would be to use this function

    CREATE FUNCTION dbo.GetEasterSunday 

        @Y INT 

    RETURNS SMALLDATETIME 

    AS 

    BEGIN 

        DECLARE     @EpactCalc INT,  

                    @PaschalDaysCalc INT, 

       ...

  • RE: Hepl with Shortlist Tables

    Right on spot, if not the case where original poster actually has an employee with id 0.

    Change code above to

    SELECT     a.ApplicantName,

               a.Specialization

    FROM       @Applicant a

    LEFT JOIN  @Shortlist s...

  • RE: How many more Mondays until I retire?

    Ok, ok ok

    Still don't get proper result with date range 1899-12-29 and 1900-01-03.

    Running

    select datediff(d, '19000101', '1900-01-03')/7 - datediff(d, '19000102', '1899-12-29')/7

    gives...

  • RE: How many more Mondays until I retire?

    Yes, it works well if not more than one of the two dates already is a monday. Using this code

    select (datediff(d, '20060213', '20060724') + 1)/7 - datediff(d, '20060213',...

  • RE: Longitude Latitude Radius

    The formulas used in this topic assumes the Earth is a perfect sphere, which it is not.

    The average radius of 3,958.755 miles is between the semi-major axis around the equator...

  • RE: How many more Mondays until I retire?

    True, and it works too. But maybe not that versatile?

  • RE: Longitude Latitude Radius

    There is really no need for calculating the distance with the ACOS/ATAN formula, since the Earth's surface doesn't curve that much for 1.5 miles (2.4 km). Pythagoras theorem will suffice...

  • RE: All Combinations

    Another possibility is that you create a cartesian product (CROSS JOIN) between the two tables.

    Something like

    SELECT      Categories.Category,

                Groups.Group,

                Groups.Block

    FROM        Categories

    CROSS JOIN  Groups

    OR

    SELECT      DISTINCT Categories.Category,

                Groups.Group,

                Groups.Block

    FROM        Categories

    CROSS JOIN ...

  • RE: join two tables

    Here is a shorter version

    -- Do the work

    SELECT      e.Employee,

                c.Code,

                c.Description,

                c.Required,

                ISNULL(h.Hours, 0) Hours

    FROM        @Employees e

    CROSS JOIN  @Codes c

    LEFT JOIN   @Hours h ON h.Code_ID = c.ID...

  • RE: Delete records wich exist in other table

    -- Find duplicate data in history table

    SELECT    Terc,

              Val,

              COUNT(*)

    FROM      Historic

    GROUP BY  Terc,

              Val

    HAVING    COUNT(*) > 1

    -- Find duplicate values between the two tables

    SELECT     ...

  • RE: join two tables

    -- Prepare test data

    declare @employees table (id tinyint, employee char(4))

    insert @employees

    select 1, 'Jack' union all

    select 2, 'Jill'

    declare @codes table (id tinyint, code smallint, description varchar(5),...

  • RE: COALESCE by UserID

    Yes, I tried your code. I am using SQL Server 2000 with SP4. I copied all your code and pasted it into QA and ran it. The output above is what...

  • RE: COALESCE by UserID

    More efficient?

    I doubt that, since you concatenate and accumulated update all rows in @table, even the duplicates. Imagine you have thousands of UserIDs where all of them have a small number...

  • RE: COALESCE by UserID

    -- prepare test data

    declare @table table (UserID tinyint, usertext char(3))

    insert @table

    select 1, 'ABC' union all

    select 1, 'DEF' union all

    select 2, 'ABC' union all

    select 3, 'ABC' union...

Viewing 15 posts - 1,936 through 1,950 (of 2,171 total)