I imported an existing SQL database which I have working.
However, I now have to reference all of my tables and views as dboXXX.tblName.
I'm trying to see if I can run a CREATE TABLE command to copy the tables and see what it does as the table owner.
The SQL Command is:
CREATE TABLE Characters2 SELECT * FROM dboXXX.tblCharacters
Query Analyzer keeps reporting an error near the SELECT.
Does anyone have any insight on how I can easily copy a table and its data?
Rather than trying to copy the tables, why not change the schema name to what you need? You can change the schema using the T-SQL command "alter schema"
See http://msdn2.microsoft.com/en-us/library/ms173423.aspx for usage and example.
Hi DevoDog,
I was having the same problem so i did something like this.
I ran an inbuilt stored procedure called "sp_changeobjectowner" in the query analyser.
This stored proc has two parameters the first being the object name according to your e.g. dboXXX.tblName and second the owner name u would prefer to be. i have mentioned an e.g below in which i change the owner to 'dbo' which is the default in most of the cases.
EXEC sp_changeobjectowner 'dboXXX.tblName', 'dbo'
You will have to repeat this for every table which has this owner i.e. dboXXX or watever by just changing the first parameter. like sayEXEC sp_changeobjectowner 'dboXXX.tblName1', 'dbo'EXEC sp_changeobjectowner 'dboXXX.tblName2', 'dbo' and so on.......
I hope this is wat u needed.