ALTER TABLE SWITCH statement failed because the object '%.*ls' is not a user defined table.

Error Message
Msg 4949, Level 16, State 1, Line 1
ALTER TABLE SWITCH statement failed because the object ‘%.*ls’ is not a user defined table. Severity level
16 Description
This error message appears, when you try to execute an ALTER TABLE SWITCH command for which neither the source nor the target a user-defined table is. Consequences
The T-SQL statement can be parsed, but causes the error at runtime. Resolution
Error of Severity Level 16 are generated by the user.  The statement can not be executed this way. Both, source and target, in an ALTER TABLE SWITCH command must be a user-defined table. Versions
This error message was introduced with SQL Server 2005. Example
USE Pubs
GO
CREATE PARTITION FUNCTION myPartFunction (int)
    AS RANGE LEFT FOR VALUES (1, 10, 100);
GO

CREATE PARTITION SCHEME myPartScheme
    AS PARTITION myPartFunction
   ALL TO ([PRIMARY]);
GO

CREATE TABLE myPartTable
(
 c1 int
)
ON myPartScheme (c1);

GO
CREATE TABLE myNonPartTable
(
 c1 int
)
ON [PRIMARY];
GO
ALTER TABLE myPartTable SWITCH PARTITION 2 TO dbo.titleview ;
GO

DROP TABLE myNonPartTable, myPartTable;
DROP PARTITION SCHEME myPartScheme;
DROP PARTITION FUNCTION myPartFunction; Remarks
In the above example we try to use the view “titleview” as the source for the ALTER TABLE SWITCH command. This raises the error.

]]>

Leave a comment

Your email address will not be published.