Avatar of madmare
Flag for Israel asked on

sql server 2008 how do I create view by other user

Hi All,
 How do I in Sql server create a View / Table by other user ?

Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
Vitor Montalvão

8/22/2022 - Mon
Koen Van Wielink

Can you please clarify what you mean with "by other user"?

my username in the server is jmua123
I have another username which is yuv123

I need a syntax write a create command which be executed as yuv123 & NOT by me jmua123

so yuv123 wil be the creator & owner etc.. of this table

something like execute command as other user
Your help has saved me hundreds of hours of internet surfing.
Koen Van Wielink

Could you clarify why you need to do this? Also, if this other user has rights to create and own a view, why don't you just login as this user and run the command under that login?

I cannot login by the second username name because the permissions are windows authentications

In addition we connect the sql server via Citrix

the second user doesn't have a citrix account, so it's a little bit difficult to login as the second user
Haris Dulic

If you wnat other user to use or be able to select from view you can grant him select by using this
GRANT SELECT ON DB_NAME.VIEW_NAME TO [your_domain_name\yuv123];

Open in new window

and if you wand that user to be able to give grants to other users you just add WITH GRANT OPTION after his username.

And since you mentioned it is domain user you need to put his username in following form [domain\user] i.e. [your_domain_name\yuv123]
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

How do I make him the owner of the table ?

not only to give him select permission
Haris Dulic

use this :

EXEC sp_changeobjectowner 'view_name', 'your_domain_name\yuv123'

Open in new window

Vitor Montalvão

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question