Forum Replies Created

Viewing 15 posts - 61 through 75 (of 116 total)

  • RE: Date Range for Join Query

    Now that I know the tables it's really getting confusing...

    You have different bookings with 1:n transactions per booking. True? OK.

    Now you're going to get...

  • RE: Date Range for Join Query

    Question: There's a HomeworkerID in both tables (tbl_hp_bookings and tbl_hp_bookings_transaction.) Why? Is it supposed to always be the same?

  • RE: Date Range for Join Query

    .... and the tbl_hp_adminusers Table?

  • RE: Date Range for Join Query

    Unfortunately, I cannot test without the tables at hand. Can you script them (using QA) ? Now that we've gone that far, we should finish it up

  • RE: Date Range & Join - supplementary question

    ?messy. I posted a solution there. That's really not how it's meant to be ....

  • RE: The conversion from datetime data type to smalldatetime data type resulted in a smalldatetime overflow error.

    Why the heck do you store the birthdate as varchar???

  • RE: HOW TO DELETE RECORDS

    or

    INSERT INTO Delete_Dup_Records

    SELECT

     D2.vid,

     D2.vName,

     D2.vAddress,

     'tricky' + D2.vGroup ,

    FROM Delete_Dup_Records D2

    GROUP BY

     D2.vid,

     D2.vName,

     D2.vAddress,

     D2.vGroup

    DELETE FROM Delete_Dup_Records WHERE vGroupName NOT LIKE 'tricky%'

    UPDATE Delete_Dup_Records SET vGroupName = SUBSTRING(vGroupName,7,8000)

    why not...

  • RE: HOW TO DELETE RECORDS

    If you don't care using a loop ... this will do

    DECLARE @affected INT

    SET @affected = 1

    WHILE @affected > 0

     BEGIN

     SET ROWCOUNT 1

     DELETE FROM Delete_Dup_Records

     FROM Delete_Dup_Records D

     INNER JOIN (SELECT vid, vName,vAddress,VGroup

        FROM Delete_Dup_Records...

  • RE: HOW TO GET THE NEW SERVERNAME WHICH WAS CHANGED AFTER SQL SERVER WAS INSTALLED

    is it actually a software? reading through the forums one can get the impression it's rather a nightmare

  • RE: Date Range for Join Query

    -- And an inline version of the above function (shoulf perform better)

    CREATE FUNCTION udf_Calc_dtHWRevenue_02

    (@dtminQuestion DATETIME)

    RETURNS TABLE

    AS

    RETURN

     (SELECT

      BK.homeworkerid,

      COALESCE(SUM(transactionamount),0) AS TransactionAmount

     FROM tbl_hp_bookings_transactions BKT

     INNER JOIN tbl_hp_bookings BK

      ON BKT.bookingid = BK.bookingid

     WHERE

       BKT.TransactionDate >=...

  • RE: Date Range for Join Query

    -- A version with a table valued UDF, just to get the idea  (NOT TESTED, care of performance)

    CREATE FUNCTION udf_Calc_dtHWRevenue

    (@dtminQuestion DATETIME)

    RETURNS @tblBookingSum TABLE (HomeworkerID INT PRIMARY KEY,

                TransactionAmount MONEY DEFAULT 0) ...

  • RE: Date Range for Join Query

    -- The basics for your special date range / just to clrify and test

    DECLARE @dtmSome DATETIME,

      @dtmStart DATETIME,

      @dtmEnd DATETIME

    SET @dtmSome = '20060223'

    SET @dtmStart = CAST(CAST(DATEPART(yyyy,@dtmSome)AS CHAR(4)) + REPLACE(STR(DATEPART(mm,@dtmSome),2),' ','0') + '01'...

  • RE: Date Range for Join Query

    In terms of patience it was surely good exercise to write this procedure.

    When I see 'one-size-fits-all' procedures like this I'd suggest you take a side...

  • RE: need help with a function

    What's your local time?

  • RE: need help with a function

    >SELECT ...., dbo.Initials ('TableName',  TableId)<

    That's what was asked for. If you prefer to replace it with a Sub-Select, this is simply different in terms of what you want -...

Viewing 15 posts - 61 through 75 (of 116 total)