Forum Replies Created

Viewing 15 posts - 1,291 through 1,305 (of 2,171 total)

  • RE: date within prior year range

    SELECT      DATEADD(YEAR, DATEDIFF(YEAR, '19000101', CURRENT_TIMESTAMP), '19000101') AS theDate UNION ALL

    SELECT      DATEADD(YEAR, DATEDIFF(YEAR, '19010101', CURRENT_TIMESTAMP), '19000101') UNION ALL

    SELECT      DATEADD(YEAR, DATEDIFF(YEAR, '19020101', CURRENT_TIMESTAMP),...


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

  • RE: CTE Help

    The real question is "Why do you think you need a CTE for this?".

    See http://www.sommarskog.se/dynamic_sql.html before you enter the land of denormalization.

     

     


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

  • RE: minumum date

    See the difference between these two queries

     

    SELECT      CustomerID,

                Item,

                ActivationDate

    FROM        (

                             SELECT      CustomerID,

                                         Item,

                                         ActivationDate,

                                         ROW_NUMBER() OVER (PARTITION BY CustomerID, Item ORDER...


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

  • RE: minumum date

    Try this

    select customerId, item, min(activationDate) from history group by customerId, item

     


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

  • RE: RTRIM not working on sysfiles column

    How about 2 * LEN() because it NCHAR?

     


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

  • RE: RTRIM not working on sysfiles column

    No need for RTRIM at all with LEN function.

     

    DECLARE

    @s-2 NVARCHAR(520)

    SET

    @s-2 = N


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

  • RE: ''''First'''' not supported in SQL Server

    SELECT Name, Age FROM (

    SELECT Name, Age, ROW_NUMBER() OVER (PARTITION BY Age ORDER BY Name) AS RecID FROM MyTab

    ) AS d WHERE RecID = 1

    SELECT Age, MIN(Name)...


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

  • RE: custid with Seqno

    declare @sample table (custid int)

     

    insert      @sample

    select      101 union all

    select      101 union all

    select      101...


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

  • RE: Eliminating duplicate rows

    DELETE f

    FROM (SELECT ROW_NUMBER() OVER (PARTITION BY Col1 ORDER BY ID) AS RecID) AS f

    WHERE RecID > 1

     


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

  • RE: insert into multiple tables... help

    -- Initialize staging

    BEGIN TRAN Yak

     

    DECLARE     @LastID INT

     

    SELECT      @LastID = MAX({Property table identity column name here})


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

  • RE: How to find the Last Date of Previous Month

    For more versatile uses of DATEADD/DATEDIFF combinations, see

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86769

     


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

  • RE: Eliminating duplicate rows

    Are you using SQL Server 2000 or SQL Server 2005?

     


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

  • RE: SQL Challenge!

    Hi Ryan. Long time no see.

    LEFT JOIN?

     

    DECLARE

    @Sample TABLE (ColA INT, ColB INT


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

  • RE: How to find the Last Date of Previous Month

    SELECT

    DATEADD(MONTH, DATEDIFF(MONTH, 0,


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

  • RE: Select column1,column2 from(exec SP_name) Where column1 = xx

    The caveat is that only the first resultset is processed

    SELECT

    a.*

    FROM OPENROWSET('SQLNCLI',


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

Viewing 15 posts - 1,291 through 1,305 (of 2,171 total)