Viewing 15 posts - 2,761 through 2,775 (of 3,008 total)
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...
July 18, 2007 at 2:21 pm
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)
July 18, 2007 at 1:58 pm
This wiil produce a random distribution of -0.05 to +0.05
select A = ((5-((abs(convert(bigint,convert(varbinary(8),newid())))%11)))*.01)
July 18, 2007 at 1:51 pm
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...
July 18, 2007 at 1:13 pm
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...
July 17, 2007 at 7:45 pm
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...
July 17, 2007 at 7:17 pm
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
July 17, 2007 at 3:54 pm
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.
July 17, 2007 at 3:06 pm
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...
July 17, 2007 at 12:12 pm
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...
July 13, 2007 at 2:06 pm
You can't do an update in a function.
July 13, 2007 at 12:20 pm
This should do it:
select * from information_schema.columns where DATA_TYPE = 'nvarchar'
July 13, 2007 at 7:52 am
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
July 12, 2007 at 4:27 pm
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.
July 12, 2007 at 4:23 pm
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...
July 11, 2007 at 5:06 pm
Viewing 15 posts - 2,761 through 2,775 (of 3,008 total)