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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 getting a list of users

Author  Topic 

BitShift
Yak Posting Veteran

98 Posts

Posted - 2008-04-04 : 13:35:04
Say I had a "typical" user table such as:

USerTable
---------
enduserid
user_name
password
firstname
lastname
...

Say this table grows very large, what would be a good way to fetch a list of users that was configurable to bring back all or some of the users ? How about a procedure that uses a range of user id's. So if you wanted ALL of you users, you just use a range of inputs that span the entire range.

comments ?


CREATE PROCEDURE EndUsers_Select
@lowuser int,
@highuser int

AS


SELECT
eu.FirstName
,eu.LastName
,ci.Email
FROM UserTable eu
JOIN ContactInformation ci ON eu.ContactInformationID = ci.ContactInformationID
WHERE EndUserID < @highuser AND EndUserID > @lowuser

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-04 : 13:38:15
Did understand fully what you told. Are you trying to get a random sample of data which covers almost all categories of users?
Go to Top of Page

BitShift
Yak Posting Veteran

98 Posts

Posted - 2008-04-04 : 13:50:40
Yes, for instance in building an admin interface to fetch ALL users, regardless of specifics. The goal im looking at is to be able to control the number of users in the results I return. So for example, when the user table gets too large, id rather not return 50,000 records to a web application. the code above doesnt show it, but im also filtering on other things such as a flag that indicates active status etc.

Actually, now that I think of it, I probably dont want to even filter at all. For this particular piece I will probably just grab all the records and then page through them using my application (C#).
Go to Top of Page
   

- Advertisement -