Showing posts with label varchar. Show all posts
Showing posts with label varchar. Show all posts

Sunday, March 25, 2012

db_datareader can't see user-defined types

I have a very simple SQL Server 2005 database, nothing fancy except that I use user-defined types (e.g., udt_Name = varchar(20)). I just set up a login for my first user, using Windows authentication, and gave her the following database access:

default schema = dbo

role = db_datareader

role = db_datawriter

Using SQL Server Management Studio, she can open any table; however, every column that is defined with a user-defined type appears with generic column headings (Expr1, Expr2 etc). And when she opens a table in design view, all columns with user-defined types have their Data Type field listed as "invalid type" rather than, say "udt_Name:varchar(20)". I browsed to the "User-defined Data Types" entry in Object Explorer, and it was empty.

In other words, it appears that she is unable to access the user-defined type aliases, even though she has read/write access to the database. As a very temporary work-around, I gave her membership in the database role "db_owner", but this is obviously not an ideal solution.

User-defined types are a great organizing tool and I don't want to have to redefine all my tables without them. What are my options?

I am not an expert on the management tools, but my guess is that most likely the reason is that db_datareader and db_datawriter roles don’t have any permission on the data type by default and therefore it fails when trying to query information about the data type.

I would suggest trying to grant VIEW DEFINITION permission to the user-defined role, for example:

GRANT VIEW DEFINITION ON TYPE::[udt_name] TO [role_name]

This will grant full access to the metadata for udt_name. You would need to do this operation for each data type.

As an alternative, and if in your security model protecting metadata on the database against this role is not a concern, you can simplify the above step for all objects in the DB:

GRANT VIEW DEFINITION TO [role_name]

I hope this information will be useful. If you still have any trouble let us know and we will try to help.

-Raul Garcia

SDE/T

SQL Server Engine

Sunday, March 11, 2012

DB question ... thanks

Suppose that I have the basic db structure as follow:

imgnum varchar(16)
description text
imagecode varchar(16)
note text
photographer varchar(16)
date date
location varchar(50)

The <imgnum> format is as follows(and its unique):
J-1 ... J-200
K-1 ... K-250
V-1 ... V-128

But some they have a few sub-images e.g: J-1 has say, J-J-1a, J-1b, J-1c
which represent the same pic but more details views; and the same with the
K-, and V- as well.

How do I structure the following in MySQL?

Thanks in advanceUseko Netsumi wrote:

>Suppose that I have the basic db structure as follow:
>imgnum varchar(16)
>description text
>imagecode varchar(16)
>note text
>photographer varchar(16)
>date date
>location varchar(50)
>The <imgnum> format is as follows(and its unique):
> J-1 ... J-200
> K-1 ... K-250
> V-1 ... V-128
>But some they have a few sub-images e.g: J-1 has say, J-J-1a, J-1b, J-1c
>which represent the same pic but more details views; and the same with the
>K-, and V- as well.
>How do I structure the following in MySQL?
>Thanks in advance
>
Suppose you explain why you posted this in just about every usenet group
you could spell.
You posted in groups for Sybase, SQL Server, Access, Dreamweaver,
Oracle, etc.
when your question has absolutely nothing to do with any of them.

Please do not post in usenet groups unless you are on-topic. And please
read the FAQ for a
group in the future before wasting everyone's time.

Thank you.

--
Daniel Morgan
http://www.outreach.washington.edu/...oad/oad_crs.asp
http://www.outreach.washington.edu/...aoa/aoa_crs.asp
damorgan@.x.washington.edu
(replace 'x' with a 'u' to reply)|||sorry for your trouble. perhaps you can tell me where should I post for this
type of question.

thanks

"Daniel Morgan" <damorgan@.x.washington.edu> wrote in message
news:1066675699.814023@.yasure...
> Useko Netsumi wrote:
> >Suppose that I have the basic db structure as follow:
> >imgnum varchar(16)
> >description text
> >imagecode varchar(16)
> >note text
> >photographer varchar(16)
> >date date
> >location varchar(50)
> >The <imgnum> format is as follows(and its unique):
> > J-1 ... J-200
> > K-1 ... K-250
> > V-1 ... V-128
> >But some they have a few sub-images e.g: J-1 has say, J-J-1a, J-1b, J-1c
> >which represent the same pic but more details views; and the same with
the
> >K-, and V- as well.
> >How do I structure the following in MySQL?
> >Thanks in advance
> Suppose you explain why you posted this in just about every usenet group
> you could spell.
> You posted in groups for Sybase, SQL Server, Access, Dreamweaver,
> Oracle, etc.
> when your question has absolutely nothing to do with any of them.
> Please do not post in usenet groups unless you are on-topic. And please
> read the FAQ for a
> group in the future before wasting everyone's time.
> Thank you.
> --
> Daniel Morgan
> http://www.outreach.washington.edu/...oad/oad_crs.asp
> http://www.outreach.washington.edu/...aoa/aoa_crs.asp
> damorgan@.x.washington.edu
> (replace 'x' with a 'u' to reply)|||Useko Netsumi wrote:

>sorry for your trouble. perhaps you can tell me where should I post for this
>type of question.
>thanks
>"Daniel Morgan" <damorgan@.x.washington.edu> wrote in message
>news:1066675699.814023@.yasure...
>
>>Useko Netsumi wrote:
>>
>>
>>
>>>Suppose that I have the basic db structure as follow:
>>>
>>>imgnum varchar(16)
>>>description text
>>>imagecode varchar(16)
>>>note text
>>>photographer varchar(16)
>>>date date
>>>location varchar(50)
>>>
>>>The <imgnum> format is as follows(and its unique):
>>> J-1 ... J-200
>>> K-1 ... K-250
>>> V-1 ... V-128
>>>
>>>But some they have a few sub-images e.g: J-1 has say, J-J-1a, J-1b, J-1c
>>>which represent the same pic but more details views; and the same with
>>>
>>>
>the
>
>>>K-, and V- as well.
>>>
>>>How do I structure the following in MySQL?
>>>
>>>Thanks in advance
>>>
>>>
>>>
>>>
>>>
>>Suppose you explain why you posted this in just about every usenet group
>>you could spell.
>>You posted in groups for Sybase, SQL Server, Access, Dreamweaver,
>>Oracle, etc.
>>when your question has absolutely nothing to do with any of them.
>>
>>Please do not post in usenet groups unless you are on-topic. And please
>>read the FAQ for a
>>group in the future before wasting everyone's time.
>>
>>Thank you.
>>
>>--
>>Daniel Morgan
>>http://www.outreach.washington.edu/...oad/oad_crs.asp
>>http://www.outreach.washington.edu/...aoa/aoa_crs.asp
>>damorgan@.x.washington.edu
>>(replace 'x' with a 'u' to reply)
>>
>>
>>
You could start by going to http://www.google.com and looking up the
product you are working with.

--
Daniel Morgan
http://www.outreach.washington.edu/...oad/oad_crs.asp
http://www.outreach.washington.edu/...aoa/aoa_crs.asp
damorgan@.x.washington.edu
(replace 'x' with a 'u' to reply)