Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-sqlserver > #705
| From | Ender Karadağ <enkaradag@gmail.com> |
|---|---|
| Newsgroups | comp.databases.ms-sqlserver |
| Subject | Help for SQLServer Session Specific Global Variable |
| Date | 2011-10-02 10:18 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <98153dbd-72d4-41da-8e97-fb3f6c1ff710@z19g2000vby.googlegroups.com> (permalink) |
Hi All, i need to declare and set a global variable that is specific to the session, each time app logs in to the sqlserver. for instance, i have a workers table that is ID,NAME,DEPARTMENTNO ID NAME DEPARTMENTNO ------------------------------------------------ 1 WORKER1 1 1 WORKER2 1 1 WORKER3 2 1 WORKER4 2 1 WORKER5 3 up to now, each user has rules to see workers on one department such as SELECT * from worker where DEPARTMENTNO=2 im doing this with query code in application, with lots of '..where DEPARTMENTNO='+inttostr(mydeptno) my application is connecting to the server and staying connected. now im thinking of a technic for doing this in sqlserver side; is there a way like: DECLARE @DEPTNO int ---variable will be static for my session SET @DEPTNO=1 ---i will do this first for my connection session.. ----- and i will have a view like; SELECT ID,NAME from worker where DEPARTMENTNO=@DEPTNO notes: 1) there are lots of users on application, all are connectiong with sa sqlserver user (so have no chance to create an sqlserver user for all app users) 2) DECLARE @DEPTNO int is working just for that query, i need one, working for all queries on that session 3) there are lots of discrete clients, so writing DEPTNO data in a table on each login fails Any idea? Thanks all;) EnKaradag
Back to comp.databases.ms-sqlserver | Previous | Next — Next in thread | Find similar
Help for SQLServer Session Specific Global Variable Ender Karadağ <enkaradag@gmail.com> - 2011-10-02 10:18 -0700
Re: Help for SQLServer Session Specific Global Variable Ender Karadağ <enkaradag@gmail.com> - 2011-10-02 10:21 -0700
Re: Help for SQLServer Session Specific Global Variable Erland Sommarskog <esquel@sommarskog.se> - 2011-10-02 19:37 +0200
Re: Help for SQLServer Session Specific Global Variable Ender Karadağ <enkaradag@gmail.com> - 2011-10-02 10:56 -0700
Re: Help for SQLServer Session Specific Global Variable Erland Sommarskog <esquel@sommarskog.se> - 2011-10-02 20:28 +0200
Re: Help for SQLServer Session Specific Global Variable Ender Karadağ <enkaradag@gmail.com> - 2011-10-02 17:30 -0700
Re: Help for SQLServer Session Specific Global Variable Erland Sommarskog <esquel@sommarskog.se> - 2011-10-03 07:16 +0000
Re: Help for SQLServer Session Specific Global Variable Ender Karadağ <enkaradag@gmail.com> - 2011-10-03 08:57 -0700
Re: Help for SQLServer Session Specific Global Variable Erland Sommarskog <esquel@sommarskog.se> - 2011-10-03 23:14 +0200
csiph-web