Forum Replies Created

Viewing 15 posts - 2,761 through 2,775 (of 3,011 total)

  • RE: Update values with random values

    Jeff, I think you need to check that formula.  It produces values in the range of -5 to +5:

    (ABS(CHECKSUM(NEWID()))%11-5)

     

    This may be closer to what you are suggesting.  It produces values in...

  • RE: x-way min

    Here is a way to do it with a subquery.  It may be handier to do it this way, because it does not require the main query to be grouped. ...

  • RE: Convert smalldatetime to int

    Good guess on my part, huh?

    My experience is that posts like this are almost always looking for a conversion to/from UNIX time, so I took a shot at it.

     

     

  • RE: Update values with random values

    You haven't posted your table structure, sample data, column datatypes, or desired results, so it is hard to tell exactly what you are after.

    It is best to test something like...

  • RE: Date stuff

    declare @StartDate datetime
    set @StartDate = '20070718'
    Select
     *
    from
     MyTable
    where
     -- Greater than or equal start of month
     MyDate >= dateadd(mm,datediff(mm,0,@StartDate),0) and
     -- Less than start of next month
    MyDate < dateadd(mm,datediff(mm,0,@StartDate)+1,0)
    
  • RE: Update values with random values

    This wiil produce a random distribution of -0.05 to +0.05

    select A = ((5-((abs(convert(bigint,convert(varbinary(8),newid())))%11)))*.01)
     
  • RE: Update values with random values

    If your objective is to increment by a random value between -5 through +5, it does not do that.  Your algorithim does not produce a random distribution, and the range is only...

  • RE: Update values with random values

    What more could I really say about them?  They seem fairly self explanatory in the links I posted on SQLTeam.

     

    I did notice that I posted the link...

  • RE: Convert smalldatetime to int

    If the integer you want to convert to is UNIX time, this will do it:

    select datediff(ss,'19700101',MySmallDateTime)

    The functions in this script can be used to convert to/from SQL Server date time...

  • RE: Update values with random values

    If you need a higher number of decimal places in your random number generation, this will give you 12 decimal places in the range of 0.95 to 1.05

     

  • RE: From SQL 7.0 to SQL 2k5

    I think that backup/restore is a better method to use for database migration from SQL 7.0 to 2005.

    I don't see how detach/attach could cause the problem you described.

     

  • RE: Query to get late week in the month

    I posted a much simpler way to get the last day of the current month in my prior post.  It also has the advantage of removing the time part of...

  • RE: Query to get late week in the month

    If your condition for the last week of the month is as simple as finding the first day of the week containing the last day of the month, the code...

  • RE: How to Update a base table from Function

    You can't do an update in a function.

     

  • RE: Is there a way to search the database for a certain datatype?

    This should do it:

    select * from information_schema.columns where DATA_TYPE = 'nvarchar'

Viewing 15 posts - 2,761 through 2,775 (of 3,011 total)