Hi. Thru a sproc, I drop & re-create some temp tables.
When I call that sproc from the client, though, I cannot drop the
tables.
I need to allow the user, say "Alex", to drop/create tables (actually,
that would be DDL). Which role should "Alex" assume ? How do I do that
?
I run the following sproc named, say, "CREATE_TAB LE" (SNIP):
_______________ _______________ _______________ _______________ ________
Set @StrSQL = 'if exists (select * from dbo.sysobjects where id =
object_id(N''[dbo].[' + @TableName + ']'') and OBJECTPROPERTY( id,
N''IsUserTable' ') = 1) drop table [dbo].[' + @TableName + ']'
Exec (@StrSQL)
Set @StrSQL = 'CREATE TABLE [dbo].[' + @TableName + '] (
[GROUP] [varchar] (6) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL ,
...........
[Stuff] [varchar] (20) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL
) ON [PRIMARY]'
Exec (@StrSQL)
Set @StrSQL = 'GRANT SELECT , UPDATE , INSERT , DELETE ON [dbo].['
+ @TableName + '] TO [Alex]'
Exec (@StrSQL)
_______________ _______________ _______________ _______________ ________
As you can see, it is dynamic, because I need to repeat it for many
@TableName values - that means, further more, that I will be executing
this in the context of the current user, Alex, and therefore I have to
give Alex rights to both executing the sproc and to the tables referred
to by the sproc, as specified by @TableName.
I created a _TEST sproc which contains only the following:
_______________ _______________ _______________ __
CREATE PROCEDURE _TEST AS
DROP TABLE [dbo].[SomeTable]
RETURN
_______________ _______________ _______________ __
When I execute it from the client, thru ADODB, on user Alex, I get
"User does not have permission to execute this operation on table
SomeTable"
The table has been created thru "CREATE_TAB LE", above
Please help, I have to finish this tomorrow, and I'm under tons of
pressure.
Thanks a lot,
Alex. 1 1447
This is usually not a good solution - if you allow users to drop and
create tables, it's very difficult to control your your database. And
if users need to dynamically create tables owned by dbo, they will need
to be in the db_owner role, which is generally not desirable.
A better option would be to have a single permanent table with the
login or SPID as part of the key (you can use a view to show each user
only their own data), or perhaps use temp tables, for which you need no
special permissions. See here for comments on the disadvantages of
dynamically creating tables (and the rest of the article for comments
on dynamic SQL in general): http://www.sommarskog.se/dynamic_sql.html#Cre_tbl
If this isn't helpful, I suggest you give some more details about what
you're trying to achieve, and why you want to create and drop tables
dynamically - someone may be able to suggest an alternative approach.
Simon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Logan |
last post by:
Several people asked me for the following HOWTO, so I decided to
post it here (though it is still very 'alpha' and might contain
many (?) mistakes; didn't test what I wrote, but wrote it - more
or less - during my own installation of Python 2.3 on Fedora Core 1
Linux for a friend of mine).
Anyway, HTH, L.
|
by: Gary |
last post by:
Hello guys!
Bear with me,I am newbie.
I am trying to limit the privileges of the user PUBLIC has as toughly
as possible which means I want to go as far as I can then leave those
MUST-HAVE privileges for user PUBLIC. The question is how far I can
go?
My expectation is once I have done this and I am asked to let my Data
|
by: KVN Chary |
last post by:
create TYPE temp1 AS OBJECT (
col1 VARCHAR2(20),
col2 VARCHAR2(20)
)
/
create TYPE temp1_array
AS VARRAY (6) OF temp1
/
|
by: Adam Smith |
last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting
site. They have done some default installations, presumably from the CVS
ports package ??. Herein lies the problem, "I do not know" what they
have done!
At first it was apparent that MySQL was installed
mysql_install_db ; GRANT TABLES etc. ???
so I ran "mysql_install_db --force"
|
by: jatinder.saundh |
last post by:
Hi,
How do I give create database privielege to a specific user/group at a
particular db2 instance ?
I read about various authorities like SYSCTRL etc. but I am interested
in giving only Create database privilege.
I also came across GRANT <system privilege statement and it seems I
can execute following statement to achieve what I want,
GRANT CREATEDBA to <authorization-name>
| |
by: Martijn Saly |
last post by:
I'd like to test in my script, if it's going to be possible to enable
priviliges.
If I use this...
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect")
....it presents a dialog to the user asking if it's ok. Now I don't want
to hide that dialog, I'd like to know if it's going to be possible to
click the Allow button, before ever making this call. Basically I need
|
by: JamesB |
last post by:
I am writing a service that monitors when a particular app is started.
Works, but I need to get the user who is currently logged in, and of course
Environment.UserName returns the service logon (NT_AUTHORITY\SYSTEM).
I understand that when the service starts, no user may be logged in, but
that's ok, as the app I am monitoring can only be run by a logged in user.
Do I need to use WMI to get the user context of Explorer.exe or is there a...
|
by: S.M.Deshpande |
last post by:
Hi,
I have installed DB2 version 8.1 and created two databases, TEST1 and
TEST2. Two operating system users test1 and test2 are mapped to two
database users in TEST1 and TEST2 databases respectively.
Even though test2 user does not exists in TEST1 database, I am able to
connect to TEST1 database using test2 user. Also able to perform basic
operations like CREATE /DROP table. After creating tables, it creates
test2 SCHEMA and DB USER ...
|
by: Rahul B |
last post by:
Hi,
I have a user UCLDEV1 which is a part of staff and a
group(db2schemagrp1) to which i have not given any permissions.
The authorizations of that user are shown as
db2 =get authorizations
Administrative Authorizations for Current User
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |