Showing posts with label ihave. Show all posts
Showing posts with label ihave. Show all posts

Wednesday, March 7, 2012

Create Login like another login...

One bit of functionality I like in Oracle's Enterprise manager, that I
haven't located in SQL Server is the ability to create a new login with all
the same rights, roles etc of an existing user.
I am using SQL Server 2005. I have tried
USP_GEN_USER_RIGHTS_BASED_ON_EXISTING_LO
GIN written by GREG LARSEN, but I ge
t
an error when executing it.
==================
Msg 213, Level 16, State 7, Line 2
Insert Error: Column name or number of supplied values does not match table
definition.
==================
Does anyone point me to a way of doing this?
PaulThat's a pretty old script you're using and it's written for SQL Server
2000, calling objects in the master database.
You can update the script using some of the security catalog views instead
of tables in master. For example, fn_my_permissions will tell you what
effective permissions the current user has.
As for the error message below, it looks like you probably had a typo
somewhere when creating or running the sproc. Probably a datatype mismatch.
joe.
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:CFECA19B-9C34-4D52-B9FC-1FA95817EE78@.microsoft.com...
> One bit of functionality I like in Oracle's Enterprise manager, that I
> haven't located in SQL Server is the ability to create a new login with
> all
> the same rights, roles etc of an existing user.
> I am using SQL Server 2005. I have tried
> USP_GEN_USER_RIGHTS_BASED_ON_EXISTING_LO
GIN written by GREG LARSEN, but I
> get
> an error when executing it.
> ==================
> Msg 213, Level 16, State 7, Line 2
> Insert Error: Column name or number of supplied values does not match
> table
> definition.
> ==================
> Does anyone point me to a way of doing this?
> Paul

Friday, February 17, 2012

Create Database problem.

Hello,
I am having problems creating a database and immediately filling it
with data. I have a sql script which i can run against a database and i
have a sql query (create database <name> ) which i run first.
My problem is that when i login to the new database i get a login
failed. If i try again (or wait a while between the "create database"
statement) and the runsqlscript function it's works OK. So it seems
that when i run "create database" the database is not completely
created when the code returns.
My psuedo code (run from c#)
//the sql script
StreamReader sr = new StreamReader(@."D:\uda.sql");
string connstr =
" server=cm041w;database=testsql;trusted_c
onnection=yes";
if (!SqlManager.Exists(connstr))
SqlManager.CreateDB" server=localhost;database=master;trusted
_connection=yes"
,"testsql");
SqlManager.RunSQLScriptOnDb(connstr,sr);//run the script against the
new dB
Internally my SqlManager uses normal T-sql queries which i can show if
necessary. Can someone explain why i need to wait between the createDB
and RunSqlScript methods'
Thanks,
Martijn
Groningen NetherlandsHave you run sp_grantdbaccess to grand db access to the login?
<mmuurman@.gmail.com> wrote in message
news:1147160273.460752.67020@.i40g2000cwc.googlegroups.com...
> Hello,
> I am having problems creating a database and immediately filling it
> with data. I have a sql script which i can run against a database and i
> have a sql query (create database <name> ) which i run first.
> My problem is that when i login to the new database i get a login
> failed. If i try again (or wait a while between the "create database"
> statement) and the runsqlscript function it's works OK. So it seems
> that when i run "create database" the database is not completely
> created when the code returns.
> My psuedo code (run from c#)
> //the sql script
> StreamReader sr = new StreamReader(@."D:\uda.sql");
> string connstr =
> " server=cm041w;database=testsql;trusted_c
onnection=yes";
> if (!SqlManager.Exists(connstr))
> SqlManager.CreateDB" server=localhost;database=master;trusted
_connection=ye
s","testsql");
> SqlManager.RunSQLScriptOnDb(connstr,sr);//run the script against the
> new dB
> Internally my SqlManager uses normal T-sql queries which i can show if
> necessary. Can someone explain why i need to wait between the createDB
> and RunSqlScript methods'
> Thanks,
> Martijn
> Groningen Netherlands
>|||when i do that i also get an error of login failed. Allthough the user
i am working in is a dbo. If i wait a while the login is automatically
created...