It should create a table,
field 1 : ID (should be filled with 5000records of random numbers)
field 2 : name (should be filled with 5000records of random character data, 15length)
Actually i'm confused on whether i should use cursors or what..
Thank you.
The following query may help you...But there is no garnetee about unique values..
Create table #Data
(
Id int,
Name varchar(20)
);
Set NOCOUNT ON;
Declare @.I as Int;
Set @.I = 0;
While @.I<5000
Begin
Insert Into #Data
Select
Cast(Rand() * 100000000as float)
, Char(65 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
+ Char(97 + cast(rand() * 1000 as int) % 26)
Set @.I = @.I + 1;
End
Select * from #Data
Drop table #Data
|||Why isSet NOCOUNT ON;
|||To suppress the Row Inserted feedback from your server.. (1 row(s) affected)
It will consume unnecessary time.. It is one of the tuning tips. You can use this wherever required.