Forum Replies Created

Viewing 11 posts - 1 through 11 (of 11 total)

  • RE: Get date for iteration of a DOW

    Full disclosure, I attempted to convert from this function I wrote 10 years ago, but am getting the math wrong now.  - I'm pretty sure each part in this script...

  • RE: Get date for iteration of a DOW

    Wait, still wrong...  I'll reply once I fix it

  • RE: Get date for iteration of a DOW

    you're right - my bad, the "DECLARE @RtrnDt" should be:
    DECLARE @RtrnDt DATE = DATEADD(DAY,((CEILING((CONVERT(DECIMAL(8, 2),17) % DATEPART(dw, @1st)) / 10) * 7) + ((@Itr*7)+@DOW+1)-7) - DATEPART(dw, @1st), @1st);

  • RE: Need To display data in Blocks (Column name: value )

    I've had a need to do similar block style within one column of the output, I used the FOR XML trick - something like:

    SELECT aa.ID

    , Stuff((Selectchar(10)+char(13)+

    'ID:' + isnull(iaa.ID,'N/A')

    +...

  • RE: Convert date to UTC date

    Here's a function I wrote to convert from central time to GMT (CST or CDT to UTC in other words) - might help:

    Create FUNCTION [dbo].[udfConvertToGMT]

    (@InputDate datetime)

    RETURNS datetime

    AS

    /*

    Script Date: 08/11/2009

    Author:...

  • RE: dynamic sql inside stored procedure?

    The Case statement in the where clause could cause performance issues if you're dealing with larger databases, I've been able to get away with using it more often than not...

  • RE: dynamic sql inside stored procedure?

    From the sound of it you could probably use Case statements. Here's an example:

    Declare @var int --decides which parts of where clause to use

    ,@var2 varchar(20)

    ,@var3 varchar(20)

    Select...

  • RE: Removing Blank Fields

    You shouldn't really be comparing an int (0) to char data (space(0)).

    The reason behind these evaluating as true (and the reason behind space(0) comparing equaly to space(1,2,3, ect..) can...

  • RE: Using IsNull when passed variable value is ''

    Another way to do it (if I'm understanding what your looking for correctly):

    SELECT @rcount=Count(*)

    FROM Table

    WHERE

    variable1=@variable1

    AND Case when isnull(@variable2,'')='' then 1

    Else...

  • RE: Linking back to original parent record

    How bout something like this?

    ;With prnt (id, mpid,lvl) AS

    (Select d.id,isnull(d.idxref,d.Id),1

    From #Data d

    UNION ALL

    Select d.id, p.mpid,p.lvl+1

    From #Data d

    Inner Join prnt p

    ond.IdXref = p.id

    )

    Select p.id,p.mpid

    from prnt p

    Inner Join (select id, max(lvl)...

  • RE: xp_cmdshell in express 2008 stripping "s?

    Never mind, I missed a \ in my script on the second server - it's always the little details that trip us up

Viewing 11 posts - 1 through 11 (of 11 total)