Forum Replies Created

Viewing 15 posts - 5,566 through 5,580 (of 6,036 total)

  • RE: Complicated Sub / Sums Query

    Secret of success is to have number of open brackets equal to number of closed brackets.

     

  • RE: User Defined FUNCTION

    There is no return for dbo.udf_date_only(@StartDate) > dbo.udf_date_only(@EndDate)

    And you repeat the same checks again and again. Not really good for performance.

    This thing does the same stuff but it's shorter and it...

  • RE: Possible recursion within sproc - what''''s the best solution?

    I use to have UDF to return a table with 2 columns: instance name (or ID) and it's level in hierarchy.

     

  • RE: Current Date minus one???

    The only possible error in this script - people like to record datetime without time portion.

    That's why you gonna take 2 ddays instead on one.

    Small chane will fix it:

    DECLARE @dtmEnd...

  • RE: Sending an email using T-SQL

    xp_sendmail

  • RE: combine second column to rows above

    What must stop from returning such set:

    col1   |   col2

    abc        456

    def         123

  • RE: HOW TO CREATE A DATABASE INSTALLER

    What about Triggers on Views?

    What about Constraints using Functions (same for Rules)?

    What about computed columns in Tables using Functions?

    What about Views using Functions?

    What about data processing SP, not only interacting...

  • RE: Avoiding Subquery in UPDATE

    Update TableA

    SET...

    FROM TableA

    Those Tablea's are actually DIFFERENT tables!

    And you don't have anything to join them in your query.

    That's why your result will not be the same as you...

  • RE: Convert Money to Text

    He is just living there.

    We are all linguists in this part of Europe.

    Vladan you did not mention...

  • RE: Delete Based On List Of Values in Stored Procedure

    Create TABLE UDF converting delimited string to set of values.

    Supply you string to this UDF as a parameter.

    Delete ...

    WHERE IdColumn in (select ReturnValue from dbo.<UDFName>(@String))

  • RE: Avoiding Subquery in UPDATE

    There is an error.

    You are updating whole TableA, not only rows matched.

    UPDATE A

    Set ColumnA = 'Test'

    from TableA A

    inner join TableB on A.ColumnB = TableB.ColumnC

    WHERE TableB.ColumnD = @Name

    OR

    UPDATE...

  • RE: Divide By Zero

    And do roundings AFTER calculations, not before!

    ISNULL(CAST(IsNull(MonthlyBookings,0) / NULLIF(CountEnqByUser,0) AS DECIMAL(18,2)) , 0)

    Oterwise you lose precision.

  • RE: Divide By Zero

    Why ISNULL???

    You are creating problems for yourself!

    Move in the opposite direction:

    ISNULL(CAST(IsNull(MonthlyBookings,0) AS DECIMAL(18,2))

       /

      CAST(NULLIF(CountEnqByUser,0) AS DECIMAL(18,2)) , 0)

  • RE: Trigger to compare incoming record w/ previous record

    Another mistake is to treat trigger on a table as a part of your page.

    It's not.

    It's a part of database functionality and nobody can guarantee that tomorrow somebody else will...

  • RE: Delete duplicate row

    You need to define which row to keep and which one to delete.

    Can you provide such definition?

Viewing 15 posts - 5,566 through 5,580 (of 6,036 total)