Loganathan Natarajan
asked on
Random Data Generation
I have a table in the following structure,
<pre lang="sql">CREATE TABLE [dbo].[RateCard](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_ AS NULL,
[rate] [money] NULL,
CONSTRAINT [PK_RateCard] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF</pre>
<pre lang="sql">insert into ratecard(name,rate)values( 'A' ;,10);
insert into ratecard(name,rate)values( 'B' ;,20);
insert into ratecard(name,rate)values( 'C' ;,25);
insert into ratecard(name,rate)values( 'D' ;,30);
insert into ratecard(name,rate)values( 'E' ;,65);
insert into ratecard(name,rate)values( 'F' ;,65);
insert into ratecard(name,rate)values( 'G' ;,10);
insert into ratecard(name,rate)values( 'H' ;,10);
insert into ratecard(name,rate)values( 'I' ;,20);
insert into ratecard(name,rate)values( 'J' ;,10);
insert into ratecard(name,rate)values( 'K' ;,10);
insert into ratecard(name,rate)values( 'L' ;,15);
insert into ratecard(name,rate)values( 'M' ;,10);
insert into ratecard(name,rate)values( 'N' ;,50);</pr e>
select *From ratecard where rate=10 order by rate
When I run the above query I get the result as follow as
1 A 10.00
7 G 10.00
8 H 10.00
10 J 10.00
11 K 10.00
13 M 10.00
When I run the query for the second time I need the output as
7 G 10.00
1 A 10.00
8 H 10.00
10 J 10.00
11 K 10.00
13 M 10.00
When I run the query for the Third time I need the output as
7 G 10.00
1 A 10.00
10 J 10.00
8 H 10.00
11 K 10.00
13 M 10.00
Each time I run the query I should get the random result. How to do it in SQL Server Query.
<pre lang="sql">CREATE TABLE [dbo].[RateCard](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_
[rate] [money] NULL,
CONSTRAINT [PK_RateCard] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF</pre>
<pre lang="sql">insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
insert into ratecard(name,rate)values(
select *From ratecard where rate=10 order by rate
When I run the above query I get the result as follow as
1 A 10.00
7 G 10.00
8 H 10.00
10 J 10.00
11 K 10.00
13 M 10.00
When I run the query for the second time I need the output as
7 G 10.00
1 A 10.00
8 H 10.00
10 J 10.00
11 K 10.00
13 M 10.00
When I run the query for the Third time I need the output as
7 G 10.00
1 A 10.00
10 J 10.00
8 H 10.00
11 K 10.00
13 M 10.00
Each time I run the query I should get the random result. How to do it in SQL Server Query.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hhhmmmm... just curious... why was my answer (being exactly the same) (and first) (and better formatted) ...;)... not accepted?
How dare you ;)