Forum Replies Created

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

  • 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'
  • RE: My Database goes read only mode

    This will do it.  You won't have to ask people to leave the DB, because it will kick them out.

    use master
    alter database MyDatabase set read_write with rollback immediate
    
  • RE: Clustered Index Scans

    Different subject, but it is usually bad idea to use NOLOCK hints, because you can get data that is uncommitted or may eventually be rolled back.

     

     

  • RE: date string conversion...

    I think this conversion method is a little shorter:

    select
    
     run_date,
     run_time,
     [Job Run Date/Time] =
     -- Convert run_date and run_time to datetime
     dateadd(ss,((run_time/10000)*3600)+(((run_time/100)%100)*60)+(run_time%100),right(run_date,8))
    from
     (
     -- Select sample of 20 jobs
     select top 20 * from sysjobhistory order by...

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