Forum Replies Created

Viewing 15 posts - 796 through 810 (of 4,080 total)

  • RE: xml as varchar datatype

    If you may have a variable number of attachments, you can use CROSS APPLY with the .nodes method to break out multiple nodes into multiple rows. The...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Is there a Coalesce LIke function that returns the lowest/highest value of a set of params passed to it

    p.s. I'm pretty sure that the presence of any NULL dates are going to throw a wrench into the gears.

    Agreed. One fix would be to add COALESCE...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Is there a Coalesce LIke function that returns the lowest/highest value of a set of params passed to it

    YSLGuru, this is the direct comparison code from Luis' time trial. Similar to the V2 logic and apparently more efficient, which you would expect because only...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: select

    I just saw your signature line, David. Are you quoting Heisenberg?

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Is there a Coalesce LIke function that returns the lowest/highest value of a set of params passed to it

    Sorry... I overwrote my earlier comment that I know of no such native functionality.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Is there a Coalesce LIke function that returns the lowest/highest value of a set of params passed to it

    And V2 is even better

    CREATE FUNCTION [dbo].[HiLoDate2]

    (

    @date1 datetime,

    @date2 datetime,

    @date3 datetime,

    @date4 datetime

    )

    RETURNS TABLE

    AS

    RETURN

    (

    with cte (max1,max2, min1,min2 ) as

    (select case when @date1 >= @date2 then @date1 else @date2...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Is there a Coalesce LIke function that returns the lowest/highest value of a set of params passed to it

    Here you go.

    ------------------------------------------

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE FUNCTION dbo.HiLoDate

    (

    @date1 datetime,

    @date2 datetime,

    @date3 datetime,

    @date4 datetime

    )

    RETURNS TABLE

    AS

    RETURN

    (

    with cte (xDate) as (

    select @date1

    union all

    select @date2

    union all

    select @date3

    union all

    select @date4

    )

    select min(xDate) as LoDate,...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Query Help

    LEFT OUTER JOIN Information_Sales A ON Case IF EID = 0 or PID = 0 then SID = 148 ELSE UDF.NEW (EID,PID) = A.SID

    Its important to remember that a CASE...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Can a JOIN be alias?

    ib.naji (10/23/2012)


    Luis Cazares (10/23/2012)


    There's no need to create a view. You'll end up with millions of views that you won't use.

    +1

    or even use a CTE.

    +1 again for the CTE

    with join_alias...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: design database

    I am not saying this sarcastically, but honestly your best approach is to outsource this work to someone who knows what they are doing with respect to SQL and database...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: many to many relations

    It might be easier for Jeff, or anyone else to give you a more detailed answer if you would illustrate what one or two of your reports look like. ...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Dynamic Footers, without dynamic SQL

    A simple REPLACE() in your SELECT is all that is needed to substitute your parameter value for the constant text in your footer. In your example:

    declare @test1...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Best way to handle Null values

    If I understand you, you want to have a default value to be returned whenever no value is specified.

    Select order_nbr, field1, field2, field3

    from table

    where order_nbr = isnull(@Ord_nbr,'xxxxxx')

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Are the posted questions getting worse?

    Cauliflower is edible? Kul Wahad!

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: OUTPUT statement question

    You can direct the OUTPUT into a table or table variable for subsequent processing.

    From BOL:

    USE AdventureWorks2012;

    GO

    DECLARE @MyTableVar table(

    EmpID int NOT NULL,

    OldVacationHours int,

    ...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 15 posts - 796 through 810 (of 4,080 total)