Forum Replies Created

Viewing 15 posts - 451 through 465 (of 3,011 total)

  • RE: Static way to get last day of the month from the past quarter

    This code will work for any date within a quarter to find the end of month for the three months in the prior querter.

    select

    CurrDateTime,

    PriorQtrMonth1 = dateadd(mm,(datediff(QQ,0,CurrDateTime)*3)-2,-1),

    PriorQtrMonth2 = dateadd(mm,(datediff(QQ,0,CurrDateTime)*3)-1,-1),

    PriorQtrMonth3 = dateadd(mm,(datediff(QQ,0,CurrDateTime)*3),-1)

    from

    (...

  • RE: Minimum Value 3 Fields > 0

    dwain.c (9/12/2012)


    Michael Valentine Jones (9/12/2012)


    dwain.c (9/12/2012)


    Another way:

    ;WITH MyValues AS (

    SELECT Id

    ,A=CASE WHEN A > 0 THEN A...

  • RE: Minimum Value 3 Fields > 0

    dwain.c (9/12/2012)


    Another way:

    ;WITH MyValues AS (

    SELECT Id

    ,A=CASE WHEN A > 0 THEN A ELSE 2147483647 END

    ...

  • RE: CONCATINATE 3 COLUMNS (int) INTO A WORKABLE DATE FORMAT

    I think this code is about as short as it gets to do this:

    select

    [DD-MM-YYYY] =

    convert(varchar(10),dateadd(mm,(12*YEAR_)-22801+MONTH_,DAY_-1),105),

    [Date]=dateadd(mm,(12*YEAR_)-22801+MONTH_,DAY_-1),

    a.*

    from

    PS_TestForOnline a

    Results:

    DD-MM-YYYY Date ...

  • RE: Puzzle : Generating two unique numbers from an array of numbers (repetation not allowed)

    This seems simple and fairly fast:

    declare @n table ( n int not null primary key clustered)

    insert into @n select top 1000 n=row_number() over(order by id)-1 from syscolumns

    select*

    from(selectx,y,z = x-y, c...

  • RE: Crazy Interviews

    a_sql (9/12/2012)


    I was asked to peel an Orange at one of my interviews..

    The ancient Japanese art of Orange-gami:

    http://www.youtube.com/watch?feature=player_embedded&v=CVHF0J8XOKM

  • RE: Minimum Value 3 Fields > 0

    select

    ID,

    [MinVal] = (

    select

    min(x)

    from

    (

    select x=A where A > 0 union all

    select x=B where B > 0 union all

    select x=C where C > 0

    ) m

    )

    from

    #MinAmt

    order by

    ID

    Results:

    ID ...

  • RE: Performance of Joins over Updates

    dwilliscp (9/7/2012)


    Michael Valentine Jones (9/7/2012)


    You haven't provided enough information for anyone to begin to answer that question.

    You should just try each way to see which is faster.

    The problem with...

  • RE: Performance of Joins over Updates

    You haven't provided enough information for anyone to begin to answer that question.

    You should just try each way to see which is faster.

  • RE: Transferring Backups

    ALIF-662928 (9/4/2012)


    Yeah we tried to copy the files into 15 smaller files,

    Did you compress the files?

    What was the total size of the compressed backup files?

    Did you copy multiple files in...

  • RE: Transferring Backups

    If you are not using one, I suggest installing a backup compression product, like Litespeed or Redgate backup, to make the files smalller. Or as an alternative, use a...

  • RE: Ridiculous

    I think any conference situation where there is a lot of consumption of alcohol, especially by young men, is likely to lead to this sort of behavior.

    This is probably why...

  • RE: when Changing DB Default SET options.

    SQL Mad Rafi (8/31/2012)


    Hi Friends,

    My problem is: the DML of a table fails, then i found that it is because of a indexed view on...

  • RE: Querying EAV data

    The thing I think is stupid about the EAV model is that it actually poorly duplicates what is already built into SQL Server: sys.tables, sys.columns, sys.types, and the tables themselves.

    The...

  • RE: Can't Kill SPID "Transaction Rollback in Progress"

    sestell1 (8/31/2012)


    guerillaunit (8/31/2012)


    Thanks Michael. I was hoping to avoid the restart, but it looks like there are no alternatives. I've never restarted a server before. Any things...

Viewing 15 posts - 451 through 465 (of 3,011 total)