Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-09 : 10:09:28
|
| avital writes "i have a database with a table and 2 columns:Phone Numbers nvarchar(13)String nvarchar (50)The phone numbers always start with +9725 and is followed by 7 other digits. I have to see many queries i can do on the database using a query of phone number that returns the string. however, the phone number i receive must be random so that each query returns a different number. how do i go about recieving this. this is what i tried to do but obviously it doesn't work:use testgoDeclare @CurrentDate datetimeDeclare @NextDate datetimeDeclare @Count intDeclare @MaxValue nvarchar (50)Declare @RandomNumber floatSet @Count=0Set @currentDate=getdate()Set @NextDate=dateadd(s,1,@CurrentDate)select @maxvalue=max ([phoneNumber]) from testselect @randomnumber=rand() * @maxvalue select @Currentdate as StartTime,@nextdate as EndTime,cast(@RandomNumber as nvarchar (50))while @currentDate<@NextDate begin select string from test where [phoneNumber]=cast(@RandomNumber as nvarchar (50)) set @Count=@Count+1 set @CurrentDate =getdate()endselect @Count as Total" |
|
|
|
|
|