Forum Replies Created

Viewing 15 posts - 616 through 630 (of 2,171 total)

  • RE: dateAdd inside where clause

    SELECTs.StoreName,

    s.StoreID,

    h.StoreDate,

    h.OpenTime,

    h.ClosingTime,

    h.Comments

    fromschema.mytable2 as s

    left JOINschema.mytable1 as h on h.[StoreID] = s.[StoreID]

    AND h.[StoreDate] between GetDate() and DateAdd(dd, 7, h.StoreDate)

    WHEREs.StoreName = 'store'


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Nth root of a number

    SELECT POWER(27.0E, 1.0E / 3.0E)

    Beware of integer division.


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Nth root of a number

    3rd root of 27 is calculated as (the positive value)

    SELECT POWER(27.0E, 1.0E / 3.0E)


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Deleting Duplicate Records

    harsha.bhagat1

    SELECT ddatetime, col1, col2

    FROM (select ddatetime, col1, col2, row_number() over (partition by ddatetime, col1, col2 order by ddatetime) as recid

    from table1

    ) as d

    where recid > 1


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Deleting Duplicate Records

    Ajay... Yes it does work.

    DELETE t1

    FROM ...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Function that finds Sundays

    SELECTDATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '19000101') AS followingMonday,

    DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '19000102') AS followingTuesday,

    DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '19000103') AS...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Function that finds Sundays

    Jeff Moden (11/24/2008)


    Your way is better because it does eliminate a couple calculations.

    Only OP can say which is right. Better is a rather subjective term.. 🙂

    SELECT DATEADD(wk,DATEDIFF(wk, '19000101', getdate()), '19000107')


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Function that finds Sundays

    Jeff's simplified.

    SELECT DATEADD(wk,DATEDIFF(wk, 0, getdate()), 6)

    However when run on a sunday, the code returns following sunday.

    My suggestion returns same sunday if run on a sunday.


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Function that finds Sundays

    SELECTDATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '18991231') AS previousSunday,

    DATEADD(DAY, DATEDIFF(DAY, '19000101', GETDATE()) / 7 * 7, '19000107') AS followingSunday


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Deleting duplicate records/rows except for 1

    DELETE f

    FROM (SELECT ROW_NUMBER() OVER (PARTITION BY code, other ORDER by code) AS recID

    FROM Table1

    ) AS f

    WHERE recID > 1

    WHILE @@ROWCOUNT > 0

    DELETE top (10000) f

    FROM (SELECT ROW_NUMBER() OVER (PARTITION...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: varbinary(float) to int

    Really well done!

    Do you have the time to test the speed of these simplified inline functions too?

    CREATE FUNCTION dbo.fnBinaryFloat2Float

    (

    @BinaryFloat BINARY(8)

    )

    RETURNS FLOAT

    AS

    BEGIN

    RETURNSIGN(CAST(@BinaryFloat AS BIGINT))

    * (1.0 + (CAST(@BinaryFloat AS BIGINT) & 0x000FFFFFFFFFFFFF)...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Job Execution Dates/Times Calculation (Past and Future Execution)

    Where did you make that change?

    Post back and I will update the blog post.


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: ORDER BY in INSERT INTO, how is it done?

    Chirag, even if there is a clustered index on the table, it doen't mean that records are stored physically in same order.

    I know Itzik Ben-Gan has demonstrated this lately.

    The index...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: CPU Utilization is 100% !!!!

    Use SQL Profiler to see which kind of activities brings server to it's knees.


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 15 posts - 616 through 630 (of 2,171 total)