How do you change the table_schema when the current table_schema is null?
up vote
0
down vote
favorite
I somehow managed to create a table in a database with a null table schema.
I can't query the table since it has no owner, and altering the table doesn't work for the same reason.
I would alter the table using:
ALTER SCHEMA null TRANSFER dbo.SubscriptionAnswerMR
But that doesn't work.
The information_schema.tables looks like this:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
q_Profiles NULL SubscriptionAnswerMR BASE TABLE
So my question is: How do I change q_Profiles' table_schema?
SQL Server 2000 (edit)
Microsoft SQL Server Management Studio 2008R2
add a comment |
up vote
0
down vote
favorite
I somehow managed to create a table in a database with a null table schema.
I can't query the table since it has no owner, and altering the table doesn't work for the same reason.
I would alter the table using:
ALTER SCHEMA null TRANSFER dbo.SubscriptionAnswerMR
But that doesn't work.
The information_schema.tables looks like this:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
q_Profiles NULL SubscriptionAnswerMR BASE TABLE
So my question is: How do I change q_Profiles' table_schema?
SQL Server 2000 (edit)
Microsoft SQL Server Management Studio 2008R2
What doessysobjectssay?
– Aaron Bertrand
May 14 '12 at 19:18
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I somehow managed to create a table in a database with a null table schema.
I can't query the table since it has no owner, and altering the table doesn't work for the same reason.
I would alter the table using:
ALTER SCHEMA null TRANSFER dbo.SubscriptionAnswerMR
But that doesn't work.
The information_schema.tables looks like this:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
q_Profiles NULL SubscriptionAnswerMR BASE TABLE
So my question is: How do I change q_Profiles' table_schema?
SQL Server 2000 (edit)
Microsoft SQL Server Management Studio 2008R2
I somehow managed to create a table in a database with a null table schema.
I can't query the table since it has no owner, and altering the table doesn't work for the same reason.
I would alter the table using:
ALTER SCHEMA null TRANSFER dbo.SubscriptionAnswerMR
But that doesn't work.
The information_schema.tables looks like this:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
q_Profiles NULL SubscriptionAnswerMR BASE TABLE
So my question is: How do I change q_Profiles' table_schema?
SQL Server 2000 (edit)
Microsoft SQL Server Management Studio 2008R2
edited May 14 '12 at 19:24
Aaron Bertrand
206k27361403
206k27361403
asked May 14 '12 at 17:32
Matt R
1,52742342
1,52742342
What doessysobjectssay?
– Aaron Bertrand
May 14 '12 at 19:18
add a comment |
What doessysobjectssay?
– Aaron Bertrand
May 14 '12 at 19:18
What does
sysobjects say?– Aaron Bertrand
May 14 '12 at 19:18
What does
sysobjects say?– Aaron Bertrand
May 14 '12 at 19:18
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You should be able to verify that your table is fine by seeing the result of the following query:
SELECT u.name
FROM q_Profiles..sysobjects AS o
INNER JOIN q_Profiles..sysusers AS u
ON o.uid = u.uid
WHERE o.name = 'SubscriptionAnswerMR';
This should be dbo unless someone explicitly created them with a different owner or used sp_changeobjectowner. Which you can use if you find that sysobjects also has the wrong answer:
EXEC sp_changeobjectowner 'SubscriptionAnswerMR', 'dbo';
ALTER SCHEMA is not valid here because it was introduced in SQL Server 2005. Though it would be useful for you to describe what "doesn't work" means.
INFORMATION_SCHEMA is a horribly unreliable set of views as @Pondlife points out. Also see the following, which doesn't help you much in SQL Server 2000, but should help going forward:
- The case against INFORMATION_SCHEMA views
Also as a side note you seem to be confused about tables and database. TABLE_CATALOG is the database, not the table.
add a comment |
up vote
1
down vote
Did you note this comment in the documentation?
Do not use INFORMATION_SCHEMA views to determine the schema of an
object. The only reliable way to find the schema of a object is to
query the sys.objects catalog view or use the OBJECT_SCHEMA_NAME
function.
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You should be able to verify that your table is fine by seeing the result of the following query:
SELECT u.name
FROM q_Profiles..sysobjects AS o
INNER JOIN q_Profiles..sysusers AS u
ON o.uid = u.uid
WHERE o.name = 'SubscriptionAnswerMR';
This should be dbo unless someone explicitly created them with a different owner or used sp_changeobjectowner. Which you can use if you find that sysobjects also has the wrong answer:
EXEC sp_changeobjectowner 'SubscriptionAnswerMR', 'dbo';
ALTER SCHEMA is not valid here because it was introduced in SQL Server 2005. Though it would be useful for you to describe what "doesn't work" means.
INFORMATION_SCHEMA is a horribly unreliable set of views as @Pondlife points out. Also see the following, which doesn't help you much in SQL Server 2000, but should help going forward:
- The case against INFORMATION_SCHEMA views
Also as a side note you seem to be confused about tables and database. TABLE_CATALOG is the database, not the table.
add a comment |
up vote
2
down vote
accepted
You should be able to verify that your table is fine by seeing the result of the following query:
SELECT u.name
FROM q_Profiles..sysobjects AS o
INNER JOIN q_Profiles..sysusers AS u
ON o.uid = u.uid
WHERE o.name = 'SubscriptionAnswerMR';
This should be dbo unless someone explicitly created them with a different owner or used sp_changeobjectowner. Which you can use if you find that sysobjects also has the wrong answer:
EXEC sp_changeobjectowner 'SubscriptionAnswerMR', 'dbo';
ALTER SCHEMA is not valid here because it was introduced in SQL Server 2005. Though it would be useful for you to describe what "doesn't work" means.
INFORMATION_SCHEMA is a horribly unreliable set of views as @Pondlife points out. Also see the following, which doesn't help you much in SQL Server 2000, but should help going forward:
- The case against INFORMATION_SCHEMA views
Also as a side note you seem to be confused about tables and database. TABLE_CATALOG is the database, not the table.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You should be able to verify that your table is fine by seeing the result of the following query:
SELECT u.name
FROM q_Profiles..sysobjects AS o
INNER JOIN q_Profiles..sysusers AS u
ON o.uid = u.uid
WHERE o.name = 'SubscriptionAnswerMR';
This should be dbo unless someone explicitly created them with a different owner or used sp_changeobjectowner. Which you can use if you find that sysobjects also has the wrong answer:
EXEC sp_changeobjectowner 'SubscriptionAnswerMR', 'dbo';
ALTER SCHEMA is not valid here because it was introduced in SQL Server 2005. Though it would be useful for you to describe what "doesn't work" means.
INFORMATION_SCHEMA is a horribly unreliable set of views as @Pondlife points out. Also see the following, which doesn't help you much in SQL Server 2000, but should help going forward:
- The case against INFORMATION_SCHEMA views
Also as a side note you seem to be confused about tables and database. TABLE_CATALOG is the database, not the table.
You should be able to verify that your table is fine by seeing the result of the following query:
SELECT u.name
FROM q_Profiles..sysobjects AS o
INNER JOIN q_Profiles..sysusers AS u
ON o.uid = u.uid
WHERE o.name = 'SubscriptionAnswerMR';
This should be dbo unless someone explicitly created them with a different owner or used sp_changeobjectowner. Which you can use if you find that sysobjects also has the wrong answer:
EXEC sp_changeobjectowner 'SubscriptionAnswerMR', 'dbo';
ALTER SCHEMA is not valid here because it was introduced in SQL Server 2005. Though it would be useful for you to describe what "doesn't work" means.
INFORMATION_SCHEMA is a horribly unreliable set of views as @Pondlife points out. Also see the following, which doesn't help you much in SQL Server 2000, but should help going forward:
- The case against INFORMATION_SCHEMA views
Also as a side note you seem to be confused about tables and database. TABLE_CATALOG is the database, not the table.
edited Nov 11 at 14:11
answered May 14 '12 at 19:21
Aaron Bertrand
206k27361403
206k27361403
add a comment |
add a comment |
up vote
1
down vote
Did you note this comment in the documentation?
Do not use INFORMATION_SCHEMA views to determine the schema of an
object. The only reliable way to find the schema of a object is to
query the sys.objects catalog view or use the OBJECT_SCHEMA_NAME
function.
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
add a comment |
up vote
1
down vote
Did you note this comment in the documentation?
Do not use INFORMATION_SCHEMA views to determine the schema of an
object. The only reliable way to find the schema of a object is to
query the sys.objects catalog view or use the OBJECT_SCHEMA_NAME
function.
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
add a comment |
up vote
1
down vote
up vote
1
down vote
Did you note this comment in the documentation?
Do not use INFORMATION_SCHEMA views to determine the schema of an
object. The only reliable way to find the schema of a object is to
query the sys.objects catalog view or use the OBJECT_SCHEMA_NAME
function.
Did you note this comment in the documentation?
Do not use INFORMATION_SCHEMA views to determine the schema of an
object. The only reliable way to find the schema of a object is to
query the sys.objects catalog view or use the OBJECT_SCHEMA_NAME
function.
answered May 14 '12 at 17:46
Pondlife
14.1k52948
14.1k52948
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
add a comment |
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Agree 100%. Except OBJECT_SCHEMA_NAME() is not valid in SQL Server 2000, nor is sysobjects. Your documentation is too new! :-)
– Aaron Bertrand
May 14 '12 at 19:21
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Absolutely right, although since the OP tagged his question as SQL 2008 (since updated) it's not surprising that I referred him to that documentation :-)
– Pondlife
May 14 '12 at 19:40
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
Ah, I missed the tag edit, sorry. :-)
– Aaron Bertrand
May 14 '12 at 19:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f10588278%2fhow-do-you-change-the-table-schema-when-the-current-table-schema-is-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does
sysobjectssay?– Aaron Bertrand
May 14 '12 at 19:18