Viewing 15 posts - 2,761 through 2,775 (of 3,011 total)
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...
July 19, 2007 at 7:34 am
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. ...
July 18, 2007 at 3:43 pm
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.
July 18, 2007 at 2:26 pm
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
Viewing 15 posts - 2,761 through 2,775 (of 3,011 total)