Forum Replies Created

Viewing 15 posts - 76 through 90 (of 327 total)

  • RE: how to get sort the rows in the order they were inserted?

    The concept of row order just does not exist in sql server.  Chris is correct! Under the circumstances you describe there is just no way you can reliably determine the order...

  • RE: Help with subquery

    I think Frank pretty much gave you everything you need to work this out.  Anyway...


    Select t1.*, t3.status_description

    From t1

    Join  t2

      on  t2.DataId = t1.DataId

     And t2.StatusChangeDate =

           (Select Max(StatusChangeDate)

            From...

  • RE: need help plz

    This may be what you are looking for:


    Select convert(char(10),getdate(),110) [current_date],

    datediff(ww,dateadd(M, datediff(M, 0, getdate()), 0),getdate()) + 1 as [week_number]

    current_date week_number

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

    06-10-2005   2


    This code gets the number of...

  • RE: Table Variable

    I'll take a look at that also.

  • RE: Table Variable

    Got it.  Thanks again. 

  • RE: Table Variable

    BTW, I do know how to view the query plan but how do you get that in text format?

  • RE: Table Variable

    I see said the blind man

    Thanks Remi

  • RE: DATETIME TO VARCHAR

    Not exactly. That produces the format yyyymmdd.  My statement (several posts above) produces the format yyyyddmm.

  • RE: DATETIME TO VARCHAR

    I also prefer to use convert but the example given by the original poster is ambiguous and I thought they were looking for a format of YYYYDDMM which I don't...

  • RE: SUM of Latest 4 dates

    Hey, that wasn't in the spec!

  • RE: SUM of Latest 4 dates


    Select Distinct version,

     (Select isnull(sum(vcount),0)

         from @datatable

      where datadate = @week3

      and version = dt.version) week3,

     (Select isnull(sum(vcount),0)

         from @datatable

      where datadate = @week2

      and version = dt.version)...

  • RE: SUM of Latest 4 dates

    Working from your first post:


    Select dt.Version, sum(dt.vcount)

    From @DataTable dt

    Where datadate IN

     (Select top 4 datadate

         From @datatable

         Where version = dt.version

         Order by datadate desc)

    Group By dt.version

    Order By dt.version


  • RE: Need urgent help

    Create a bit flag for each column that may need to be updated and use an update statement similar to this:


    update YourTable

      set col1 =

      case

         when(@col1_change=1) then @new_col1_val

         else col1

      end,

      col2 = ...


  • RE: DATETIME TO VARCHAR

    If you're looking for the format to be yyyyddmm


    select cast(datepart(yy,getdate()) as varchar) +

           Right ('00' + cast(datepart(dd,getdate())as varchar),2) +

           Right ('00' + cast(datepart(mm,getdate()) as varchar),2)


                                   

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

    20050906

    Edit:...

  • RE: Extended challenge for everyone

    I had an idea you were enumerating something but I wasn't quite sure what was going on.  Also I was confused by this syntax set @Int = Colid2 =...

Viewing 15 posts - 76 through 90 (of 327 total)