Change Connected User To Avoid Owner Prefix In Queries
Mar 16, 2007
Hi everybody,
I've five instances of SQL Server 2000 with the SAME database with a
DIFFERENT owner in each server. I, as the administrator, have a lot of
queries that I have to execute in some or all servers. The problem is
that I have to connect to all servers with MY user, not each of the db
owners...
So I have queries this way:
select * from mike.table1 t1 join mike.table2 t2 on...
And when I connect to another server I have to change mike for jeremy
in all the SQLs...
And when I connect to another server I have to change jeremy for nina
in all the SQLs...
I know that there was an old, v7, deprecated way to change the
"schema", something like
change current user to kimberly
go
select * from table1 t1 join table2 t2 on...
This way, I'll change ONLY once the connected user. I could even do at
the beginning of the script an IF, to change the connected user
depending on @@SERVERNAME !!!
Hello, We had a developer that created some user defined data types. He is no longer with our company and we want to change owner of those user defined data types so we will be able to delete his UUID. Is their a way to change the owner of the user defined data types from his ID to dbo. I don't see a way to change them with sp_changeobjectowner
For our ETL process, we maintain a TransformationList table that has the source view and the destination table. Data is copied from the view into the table (INSERT INTO). I am trying to find column names in the Views that are not column names in the associated Table.
In the below example, want to end up with three records:
I have it almost working, except that there is a table, ChangeColPrefix table, that is used by the ETL process to change some of the view's column name prefixes. Some of the source views have column names with prefixes that do not match the destination table column names. Say view SouthBase has all the column names prefixed with SB - like SBAcct, SBName. And the Destination table of Area District has ADAcct, ADName. There would be a row in the ChangeColPrefix for SouthBase, SB, AD, 1, 2 that would be used by the ETL process to create the INSERT INTO Area District From SouthBase.
I need to use this ChangeColPreifx to find my unmatching columns between my source views and destination tables. With out that table SBAcct and SBName from SouthBase will not appear to match the columns of ADAcct and ADName, but they do match.
I want to end up with these three records as non-matching:
View1, Column4 View2, Column4 View2, Column5
View1 has Salumn2 and View2 has Salumn5, and they must be changed to Column2 and Column5 as per the ChangeColPrefix table before running the Select from INFORMATION_SCHEMA.COLUMNS EXCEPT Select from INFORMATION_SCHEMA.COLUMNS looking for unmatched columns.
/***** Set Up Test Data *****/ -- Create 2 test views IF EXISTS(SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View1]')) DROP VIEW dbo.[View1] GO CREATE VIEW View1 AS SELECT '1' AS Column1 , '2' AS Salumn2 , '4' AS Column4;
Having some issues with our apps. We are trying to get our applications to work with sql2005.
Ive got the databases "setup", and all our apps run fine... ...except for when queries are made without the owner of the table being specified in the query.
The connection is opened with the username that is associated with that owner. And it fails in Manager as well. Is there something im missing, because you should be able to do this.
eg: select * from <table_name>
Gives the error:
Msg 208, Level 16, State 1, Line 1
Invalid object name '<table_name>'.
However if i were to query like this: select * from <owner>.<table_name>
hi, I just imported my access database into sql server 2000 and apparently during this importation the owner was set to my name. This gives my a problem retrieving the data in asp.net though. I found out that the problem (System.Data.SqlClient.SqlException: Invalid object name 'tablename') is situated at this ownership by stripping the query to a bare minimum and trying it on a new table created in sql server with dbo as the owner. My problem now is that I can't seem to find the way to change the owner to dbo from 'peterj'. Can you help me on this one ??
I have several Production Databases on my SQL Server 2000 Standard Edition Server (mixed mode authentication) that I'd like to change DBO Permissions on. When I look at the Properties of the DB(s) from EM, the Database owner is showing up as a Windows NT USer who is no longer even with the company!!
Can I use the sp_changedbowner 'sa' command to change the database owner to sa without disrupting Production? Might sound like a dumb question.. but ya never know!!!!! Also, I had someone on another forum tell me that 'sa' as db owner is a bad idea but I don't know why??????? can anyone elaborate on that?????
I need to change the owner of all stored procedures from x to y. I know there is a sp_changeobjectowner sp, which does that, but in that way I will have to write a loop to get all sps which are owned by user x. Can somebody help me with that?
Hello,I'm using tableadapters in VWD 2005 Express to link our ASP.NET application to a SQL Server 2000 database. Initially, I used Database Explorer to drop tables into the DataSet object, which picks up the owner of the tables from the database.Recently, we had to change the owner of all objects in the database, including tables and stored procedures. When we run our application it chokes on stored procedures because the owner of the SP's has changed. My question is: how can I update tables and tableadapters in the DataSet to reflect the change in owner, without having to recreate everything in DataSet?
Hi,I just transferred my website and database (SQL 2000) to a new host who's SQL Manager doesn't support the previous username I had for the database.The previous owner of database tables etc was Database_master and now I want to change it to just Master.Please advise! Someone else designed the website for me, and honestly I have just some basic knowledge of databases and such.I would appreciate help and if possible with detailed steps.Many thanks in advance,Isje
Hello, I'm trying to access the Database Diagram of a sql database I created but am getting the error:
"The database does not have a valid dbo user" I also noticed that my NT group user was incorrect and this is the name being used as the owner of the database. How do i change this?
i have around 100 stored procedures that are created by andrew user and now i want to change the owner of all these SP's to DBO is there any way to do it....
or
do i need to manually do it for each and every object seperately...
We set up a few tables while being logged in as a different user. Now, those tables are not accessible via some ASP pages because they aren't DBO-owned tables. Relationships do exist on these tables, but no significant data. Is there a way to change the owner, or do I need to delete the table and start over?
Using SQL Server 7.0Trying to change an objects ownership to dbo withEXEC sp_changeobjectowner 'AssignInvoiceNumbers', 'dbo'which gives the following error:Server: Msg 15001, Level 16, State 1, Procedure sp_changeobjectowner,Line 26AssignInvoiceNumbers does not exist.which it does.Any help would be greatly appreciated--Nath(Email mangling obvious)*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
Hi, i want to change owner to my dts package. Can i do this problem to this procedure? ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' update sysdtspackages set owner = 'newname' where owner ='oldname' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Because in this case i update all old name. I also test sp_reassign_dtspackageowner but i don't know how this comand to do on the table?
I restored and renamed a client database from a backup file to my laptop (both SQL Express 2005) and noticed that no owner had been assigned. I set the db-owner to SA. This database will replace a local version of the same database that was created on my laptop. (The customer has entered data...)
When I start the dataset configuration wizard in VS2005 all tables appear twice in the list. Once with the original name and once with the prefix dbo. For example: Customer and dbo.Customer.
The tables with the dbo. prefix are marked with a Red Cross in the checkbox. Hovering over them display the error message: "Element .. in the dataset references an object missing from the database. "
The tables without the dbo. prefix are not marked. When I mark these tables VS2005 indicates that the table will be renamed to Customer1. The same issue applies to all the views in the database.
Is there a way to solve this problem without having to recreate the entire dataset? I'd rather not do that cause I added some queries to the dataset and they will be lost and have to be recreated.
SQL Server 2012R2 Express, I need to change db owner from Domain1User1 to Domain2User1.
Both SQL login Domain2User1 and db user Domain2User1 exist; db user Domain2User1 is mapped to SQL login Domain2User1.
When I try to change db owner from Domain1User1 to Domain2User1
I get the error:
This article does not imply any restrictions on users that can be made db owners: [URL]....
"In SQL Server, the owner of the current database can be changed. Any user, a SQL Server login or Microsoft Windows user, who has access to connect to SQL Server can become the owner of a database."
Why can't I make the owner of a db an SQL login that have a mapped user in that db?
I have verified that myaspx error was due to the owner of the table is not dbo. However, I don't know how to use sp_changeobjectowner to change the table owner to dbo. I even tried sp_changetableowner, but didn't work. SQL Server gave me a hint of '@newowner' parameter; still, I could not get it.