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 2000 Forums
 SQL Server Development (2000)
 Best way to share table among users

Author  Topic 

slacker
Posting Yak Master

115 Posts

Posted - 2003-02-08 : 18:16:24
Im not sure if Im doing this the best way. We have an application that will be shared amongst clients. They will share the same table yet the info that is inserted and added must be only queried and updated by the same client. So for instance if it were a messageboard application. 5 clients could have their own instance of the messageboard only being able to view, modify and work with data added for their messageboard.

So anyways. What I have done is... created a new user for each client. I created a field called ClientSID which stores the SID of the user in this field using the function SUSER_SID() as a default value. Then... what I did was create a view for all data retrieval operations on the table.. And the view basically will select only records with the same SUSER_SID(). Then the stored procs just select and update from the view. The client app knows nothing of this it just calls the stored procs.

Is there a better or more proven method of doing this? Or am I on the right track? TIA.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-02-08 : 19:52:44
I've done it a little bit more manually than that. I have a client ID in all the important tables and pass that in to my stored procs and manually filter the queries.

Damian
Go to Top of Page

slacker
Posting Yak Master

115 Posts

Posted - 2003-02-08 : 20:59:53
Would the lookup speed be slower if I used the varbinary then a regular int such as you have done? I was planning on indexing the ClientSID field and possibly even indexing the views. But I dont want the insert/update performance to suffer by having too many index's. So I may just stratch having the views and just manually do the query as you have done. But I still want to find the id within the stored proc somehow. I dont want the application to know or care about its client id.

Go to Top of Page
   

- Advertisement -