Showing posts with label assigned. Show all posts
Showing posts with label assigned. Show all posts

Monday, March 26, 2012

Rights assigned to Windows\Power Users in SQL Express.

Hi,

In SQL Server Express Edition, what are the rights that are assigned to a Normal Windows User and PowerUser by default ?

When I install SQL Express on a clean machine and login as Power User I can add/edit/delete data but when I login as Normal Windows User I can see the data but not change it.

Please help me in this regard.

Thanks and Regards,
Gautham.

What do you mean exactly by the ability to add/edit/delete data; what kind of data is that?

In SQL Server Express, members of Builtin\Administrators are members of the sysadmin server role. Members of Builtin\Users are only granted the connect sql permission. There is no special provisioning for Builtin\Power Users, so they would just have the same right on SQL Server Express as a "normal" user.

To verify if a principal has a special permission, you can use the has_perms_by_name builtin. For example, to check if a user has select on table t, you can execute:

select has_perms_by_name ('t', 'object', 'select')

while connected as that user.

For additional information, you can check the following catalogs:

sys.server_principals
sys.server_permissions
sys.login_token
sys.database_principals
sys.database_permissions
sys.user_token

Thanks
Laurentiusql

Friday, March 23, 2012

Right to create db diagrams

Hello,
Does anyone knows which right has to be assigned to a user so that it can cr
eate a database diagram.
Indeed, we currently have users having the rights of connection and the role
s following: db_datareader, db_datawriter and db_ddladmin.
With these roles, the creation of a new diagram of dB raises an error indica
ting that the user does not have the authorizations necessary to create a ne
w diagram.
Which role, or grant XX, can solve this concern?
thanks
AlexandreWhat version of SQL Server and what is the exact error
message?
If you are on SQL Server 2000, the users in those roles
should be able to create the diagrams under most
circumstances. The warning that initially pops up would be
something like "you aren't logged on as database owner or
system administrator. You might not be able to save changes
to tables that you don't own" but that won't prevent them
from actually creating the diagram
If the error you get is "You do not have sufficient
privileges to create the new diagram", then you may be
running into the following issue:
FIX: You Cannot Create Diagrams in SQL Enterprise Manager If
You Are Not a Database Owner
http://support.microsoft.com/?kbid=327145
-Sue
On Tue, 16 Mar 2004 01:16:08 -0800, "Alex"
<anonymous@.discussions.microsoft.com> wrote:

>Hello,
>Does anyone knows which right has to be assigned to a user so that it can c
reate a database diagram.
>Indeed, we currently have users having the rights of connection and the rol
es following: db_datareader, db_datawriter and db_ddladmin.
>With these roles, the creation of a new diagram of dB raises an error indic
ating that the user does not have the authorizations necessary to create a n
ew diagram.
>Which role, or grant XX, can solve this concern?
>thanks
>Alexandre|||Hi,
Thanks for the input.
I was running into the issue you have mentionned, and the workaround in the
note works fine to correct this.
Alex

Friday, March 9, 2012

returns null not cost value in SP

I do not understand what I am doing wrong. I have no problem getting the
value into @.tot but I cannot get the value assigned to @.item_cost. When I
use the debug mode, it says @.item_cost is null before the start of the debug
and after the debugging is done.
CREATE PROCEDURE test
@.id int,
@.item_cost money = NULL out
AS
declare @.tot money
select @.tot = convert(money,(field_value))
from tbl
where field_id = @.id
and field_code = 901
set @.item_cost = @.tot
GO
Grant
Who gives a {censored} if I am wrong.--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
Why have the intermediate variable @.tot? Why not just assign the value
in the SELECT statement to the variable @.item_cost. And, why set a
default of NULL on the OUTPUT variable when, if the SELECT command
doesn't pick up anything, it will be NULL anyway?
CREATE PROCEDURE test
@.id int,
@.item_cost money out
AS
select @.item_cost = convert(money, field_value)
from tbl
where field_id = @.id
and field_code = 901
GO
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBRFJOv4echKqOuFEgEQJPPwCfcFbZUZ5LjwCf
r6w/ssa5DdXaul8Ani4G
M3i/xn7vb7/mwkxaXsdhqe9B
=nln8
--END PGP SIGNATURE--
Grant wrote:
> I do not understand what I am doing wrong. I have no problem getting the
> value into @.tot but I cannot get the value assigned to @.item_cost. When I
> use the debug mode, it says @.item_cost is null before the start of the deb
ug
> and after the debugging is done.
>
>
> CREATE PROCEDURE test
> @.id int,
> @.item_cost money = NULL out
> AS
>
> declare @.tot money
>
> select @.tot = convert(money,(field_value))
> from tbl
> where field_id = @.id
> and field_code = 901
>
> set @.item_cost = @.tot
> GO
>|||I was struggling on getting the values returned back to me so I added
intermediate variable and I found that I was getting the expected result but
only to @.tot not @.item_cost. I made the changes to the query to match your
example and it still returns null instead of 20.00.
Grant
Who gives a {censored} if I am wrong.
"MGFoster" <me@.privacy.com> wrote in message
news:a9s4g.5073$An2.3038@.newsread2.news.pas.earthlink.net...
> --BEGIN PGP SIGNED MESSAGE--
> Hash: SHA1
> Why have the intermediate variable @.tot? Why not just assign the value
> in the SELECT statement to the variable @.item_cost. And, why set a
> default of NULL on the OUTPUT variable when, if the SELECT command
> doesn't pick up anything, it will be NULL anyway?
> CREATE PROCEDURE test
> @.id int,
> @.item_cost money out
> AS
> select @.item_cost = convert(money, field_value)
> from tbl
> where field_id = @.id
> and field_code = 901
> GO
> --
> MGFoster:::mgf00 <at> earthlink <decimal-point> net
> Oakland, CA (USA)
> --BEGIN PGP SIGNATURE--
> Version: PGP for Personal Privacy 5.0
> Charset: noconv
> iQA/ AwUBRFJOv4echKqOuFEgEQJPPwCfcFbZUZ5LjwCf
r6w/ssa5DdXaul8Ani4G
> M3i/xn7vb7/mwkxaXsdhqe9B
> =nln8
> --END PGP SIGNATURE--
> Grant wrote:|||Very confuse now. I got it to work but I have to print it, why? Changes are
in ucase.
CREATE PROCEDURE test
@.id int,
@.item_cost money = NULL out
AS
declare @.tot money
select @.tot = convert(money,(field_value))
from tbl
where field_id = @.id
and field_code = 901
set @.item_cost = @.tot
PRINT CONVERT(VARCHAR, @.item_cost))
GO
Grant
Who gives a {censored} if I am wrong.
"Grant" <email@.nowhere.com> wrote in message
news:%23FEYkSuaGHA.4564@.TK2MSFTNGP03.phx.gbl...
>I do not understand what I am doing wrong. I have no problem getting the
>value into @.tot but I cannot get the value assigned to @.item_cost. When I
>use the debug mode, it says @.item_cost is null before the start of the
>debug and after the debugging is done.
>
>
> CREATE PROCEDURE test
> @.id int,
> @.item_cost money = NULL out
> AS
>
> declare @.tot money
>
> select @.tot = convert(money,(field_value))
> from tbl
> where field_id = @.id
> and field_code = 901
>
> set @.item_cost = @.tot
> GO
>
> --
> Grant
> Who gives a {censored} if I am wrong.
>|||--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
Can you execute the SP from Query Analyzer? E.g.:
declare @.output money
exec test 255, @.item_cost = @.output OUTPUT
print @.output
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA+AwUBRFJnxoechKqOuFEgEQI+tACgljJ1DN4D
4IfLakOmWRWehBNUQBMAl2eH
YynUqeXDsI6xI87T63C9SbM=
=lDfp
--END PGP SIGNATURE--
Grant wrote:
> Very confuse now. I got it to work but I have to print it, why? Changes ar
e
> in ucase.
>
> CREATE PROCEDURE test
> @.id int,
> @.item_cost money = NULL out
> AS
> declare @.tot money
> select @.tot = convert(money,(field_value))
> from tbl
> where field_id = @.id
> and field_code = 901
> set @.item_cost = @.tot
> PRINT CONVERT(VARCHAR, @.item_cost))|||On Fri, 28 Apr 2006 14:00:37 -0400, Grant wrote:

>I was struggling on getting the values returned back to me so I added
>intermediate variable and I found that I was getting the expected result bu
t
>only to @.tot not @.item_cost. I made the changes to the query to match your
>example and it still returns null instead of 20.00.
Hi Grant,
How do you call the procedure?
EXEC test @.id = 1,
@.item_cost = @.result_variable
is WRONG!! (And I expect that this is how you currently do it).
The correct call is
EXEC test @.id = 1,
@.item_cost = @.result_variable OUTPUT
Note the addition of OUTPUT to specify that @.item_cost is an output
variable. You have to specify this both in the CREATE PROCEDURE and in
the EXECUTE statement in order to make it work.
Hugo Kornelis, SQL Server MVP

Saturday, February 25, 2012

Returning role memberships FROM sql Server

A problem: I created some user defined roles in SQL SERVER 2000 and assigned users to different roles. Can you help me with a way (stored procedure etc.) to return the correct roles of my logged in users to my ASP.NET application.

Well if you have a table of logged in users you just have to do an Inner Join

SELECT *
FROM LoggedInUsers liu INNER JOIN Roles r ON liu.role_id = r.id

Tuesday, February 21, 2012

returning key value with Insert

I'm using SQL-MSDE and have a table defined with a 'identity seed' column that automatically gets assigned when a record is added (I do not load this value). This column is also my KEY to this table. I'm using INSERT to add a record. Is there a way to return this KEY value after doing the INSERT?
Hello,
Use SCOPE_IDENTITY() or @.@.IDENTITY
e.g
SELECT @.@.IDENTITY
HTH
regards
|||

Thanks. Sorry, I still don't understand (fairly new to ASP.net). Code is below. After my 'ExecuteNonQuery' command is performed, I want to know the value of the IdentityColumn (not referenced in code below) that was automatically added. ?? Thanks for your patience.
******************************************************************************************


PublicSharedFunction AddReport(ByVal passRepLayoutAs Report)AsBoolean

Dim dbConnectionAs SqlConnection = QuoteDBConnection()

Dim sAddAsString = "Insert Into Report(QuoteNumber, Driver, ReportType, ReportID, OrderDate, DataFile) " _

& "Values(@.QuoteNumber, @.Driver, @.ReportType, @.ReportID, @.OrderDate, @.DataFile)"

Dim dbCmdAsNew SqlCommand(sAdd, dbConnection)

With passRepLayout

dbCmd.Parameters.Add("@.QuoteNumber", .QuoteNumber)

dbCmd.Parameters.Add("@.Driver", .Driver)

dbCmd.Parameters.Add("@.ReportType", .ReportType)

dbCmd.Parameters.Add("@.ReportID", .ReportID)

dbCmd.Parameters.Add("@.OrderDate", .OrderDate)

dbCmd.Parameters.Add("@.DataFile", .DataFile)

EndWith

dbConnection.Open()

Try

dbCmd.ExecuteNonQuery()

IdentityColumnValue = ?

AddReport =True

Catch exAs Exception

AddReport =False

EndTry

dbConnection.Close()

EndFunction

|||

Dim sAddAsString="Insert Into Report(QuoteNumber, Driver, ReportType, ReportID, OrderDate, DataFile) " _

&"Values(@.QuoteNumber, @.Driver, @.ReportType, @.ReportID, @.OrderDate, @.DataFile) SELECT SCOPE_IDENTITY()"

and use ExecuteScalar instead of ExecuteNonQuery.
dim resultidasinteger

resultid= dbCmd.ExecuteScalar()

|||Thank- you very much.