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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select records from a room

Author  Topic 

stineco
Starting Member

6 Posts

Posted - 2005-08-22 : 05:01:36
i need a script that:
select all records from a room, if the records in that room have a recordcount less then 100 records continue with next room until
we have 100 records, the next time i run this script, i must give me other rooms (random)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 05:06:34
Is this?

Select top 100 rooms from room order by newid()

Otherwise post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

stineco
Starting Member

6 Posts

Posted - 2005-08-22 : 05:13:25
the table is eq (equipement)not rooms
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 05:17:44
Replace rooms by eq

Select top 100 rooms from eq order by newid()

If you dont get your desired output, post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

stineco
Starting Member

6 Posts

Posted - 2005-08-22 : 05:32:14
When i use this it doesn't give me the ALL the records of that room records

i just want to select all records of a room, (room 00.01) When the records are less then 100 go to (room 00.02),(room 00.03) until we reach 100 records

result i want

id 01room 00.01
id 02room 00.01
id 03room 00.01
id 04room 00.01
id 05room 00.01
id 06room 00.01
id 07room 00.01
id 08room 00.01
id 09room 00.02
id 10room 00.02
id 11room 00.02
id 12room 00.02
id 13room 00.04
id 14room 00.04
id 15room 00.04
id 16room 00.04

go until we reach 100 records



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 05:37:03
Select top 100 rooms from eq where rooms >='00.01' order by rooms


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

stineco
Starting Member

6 Posts

Posted - 2005-08-22 : 05:46:34
this works,
but the next time i run the script it must give me other rooms
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 05:56:25
Try this

Select * from (
Select top 100 rooms from eq
where rooms >='00.01'order by newid()
) T order by rooms


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

stineco
Starting Member

6 Posts

Posted - 2005-08-22 : 07:31:19
i tried this
Select rm_id,omschrijving from (
Select top 100 * from eq
where bl_id='004' and fl_id in ('02','04') and rm_id >='00.01'order by newid()
) T order by rm_id

when i run the script the second time he dont get all the records of a room
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-08-22 : 10:29:25
instead of chasing our tails...follow the instructions in the hint link below....



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -