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
 Transact-SQL (2000)
 SELECT and INSERT Question

Author  Topic 

Sanch
Starting Member

2 Posts

Posted - 2005-11-24 : 15:28:03
Hello,

I have the following situation.

I have a table where I have two columns, the first column is user, and second column is privilege.

so for each user, there could be 100s of privilege associated with them.

Now what I need to do on this table is. I need to check if a user has a certain privilege, if the user does have that particular privilege, then I need to add 10 new privilege to this table.

What I have so far is:

select user from user_priv where privilege_id=100

insert into user_priv values(user, 200)
insert into user_priv values(user, 201)
insert into user_priv values(user, 202)
insert into user_priv values(user, 203)
insert into user_priv values(user, 204)
insert into user_priv values(user, 205)
and so on until 210.

Can you help me with this and tell me how to do this?

Thanks
Sanch

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-24 : 19:24:04
insert user_priv
select user, i+200
from (i = 0 union select 1 union select 2 .... union select 10) a
where privilege_id = 100

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -