Monday, March 26, 2012
Retriving users, roles and roles assigned to each user from the database.
it in enterprise manager. Is there a way to query the
database for the follwing informations below.
1) a list of database users
2) what roles are set up in the database
3) which users are assigned to which roles (i.e. what
privs do the users have)
"Aboki" <hcokoli@.yahoo.com> wrote in message
news:c5d601c47a3d$6847dbb0$a501280a@.phx.gbl...
>
> How do I get this information without manually check for
> it in enterprise manager. Is there a way to query the
> database for the follwing informations below.
> 1) a list of database users
> 2) what roles are set up in the database
> 3) which users are assigned to which roles (i.e. what
> privs do the users have)
1. SELECT * FROM sysusers WHERE issqlrole = 0
2. SELECT * FROM sysusers WHERE issqlrole = 1 OR isapprole = 1
3. exec sp_helprolemember
HTH
Rick Sawtell
MCT, MCSD, MCDBA
Retriving users, roles and roles assigned to each user from the database.
it in enterprise manager. Is there a way to query the
database for the follwing informations below.
1) a list of database users
2) what roles are set up in the database
3) which users are assigned to which roles (i.e. what
privs do the users have)"Aboki" <hcokoli@.yahoo.com> wrote in message
news:c5d601c47a3d$6847dbb0$a501280a@.phx.gbl...
>
> How do I get this information without manually check for
> it in enterprise manager. Is there a way to query the
> database for the follwing informations below.
> 1) a list of database users
> 2) what roles are set up in the database
> 3) which users are assigned to which roles (i.e. what
> privs do the users have)
1. SELECT * FROM sysusers WHERE issqlrole = 0
2. SELECT * FROM sysusers WHERE issqlrole = 1 OR isapprole = 1
3. exec sp_helprolemember
HTH
Rick Sawtell
MCT, MCSD, MCDBA
Retriving users, roles and roles assigned to each user from the database.
it in enterprise manager. Is there a way to query the
database for the follwing informations below.
1) a list of database users
2) what roles are set up in the database
3) which users are assigned to which roles (i.e. what
privs do the users have)"Aboki" <hcokoli@.yahoo.com> wrote in message
news:c5d601c47a3d$6847dbb0$a501280a@.phx.gbl...
>
> How do I get this information without manually check for
> it in enterprise manager. Is there a way to query the
> database for the follwing informations below.
> 1) a list of database users
> 2) what roles are set up in the database
> 3) which users are assigned to which roles (i.e. what
> privs do the users have)
1. SELECT * FROM sysusers WHERE issqlrole = 0
2. SELECT * FROM sysusers WHERE issqlrole = 1 OR isapprole = 1
3. exec sp_helprolemember
HTH
Rick Sawtell
MCT, MCSD, MCDBA
Monday, March 12, 2012
Retrieving Default Values for Parameters in a Stored Procedure.
To retrieve the parameter information I use:
sp_sproc_columns @.Procedure_Name='InsertUser''
However, the column that is supposed to give the default value,'COLUMN_DEF' always returns as NULL, even when that column has adefault value assigned to it.
i.e.
CREATE PROCEDURE InsertUser
@.UserID INT = 10,
....
And then if I do a sp_sproc_columns @.Procedure_Name='InsertUser'', the COLUMN_DEF value for the @.UserID column is still NULL.
Does anyone know what I'm doing wrong and how I can retrieve the default value?
Thanks
It looks like you will have to parse the stored procedure code to get the default parameter info:
http://www.aspfaq.com/show.asp?id=2463
Hope this helps.
Chris R. Timmons
--------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Wednesday, March 7, 2012
retrieve the GUID for inserted record
I am using this code to insert a record in my table where i have assigned a guid datatype field to generate an automatic guid for each record. but now i need to retrieve the guid to use it to send a confirmation email to the user.
SqlConnection sql_connection = new SqlConnection("Server=xxx.xxx.xx.xxx;uid=xxxxxxxx;password=xxxxxxx;database=xxxxxxx;");
SqlCommand sql_command = new SqlCommand("INSERT INTO members (member_sex, member_cpr, member_nationality, member_block, member_gov, member_daaera, member_email, member_mobile, member_created_ip) Values (@.member_sex, @.member_cpr, @.member_nationality, @.member_block, @.member_gov, @.member_daaera, @.member_email, @.member_mobile, @.member_created_ip)", sql_connection);
sql_command.Parameters.Add(new SqlParameter("@.member_sex", Session["member_sex"].ToString()));
sql_command.Parameters.Add(new SqlParameter("@.member_cpr", Session["member_cpr"]));
sql_command.Parameters.Add(new SqlParameter("@.member_nationality", Session["member_nationality"].ToString()));
sql_command.Parameters.Add(new SqlParameter("@.member_block", Session["member_block"].ToString()));
sql_command.Parameters.Add(new SqlParameter("@.member_gov", "GOV"));
sql_command.Parameters.Add(new SqlParameter("@.member_daaera", 6));
sql_command.Parameters.Add(new SqlParameter("@.member_email", Session["member_email"].ToString().ToLower()));
sql_command.Parameters.Add(new SqlParameter("@.member_mobile", Session["member_mobile"].ToString()));
sql_command.Parameters.Add(new SqlParameter("@.member_created_ip", Request.UserHostAddress.ToString()));
sql_connection.Open();
sql_command.ExecuteNonQuery();
sql_connection.Close();
Create the GUID yourself, and pass it into the insert.