ALTER TABLE SWITCH statement failed because column ‘%.*ls’ has data type %s in source table ‘%.*ls’ which is different from its type %s in target table ‘%.*ls’.

$0Error Message:$0Msg 4944, Level 16, State 1, Line 1$0ALTER TABLE SWITCH statement failed because column ‘%.*ls’ has data type %s in source table ‘%.*ls’ which is different from its type %s in target table ‘%.*ls’.$0$0Severity level:$016.$0$0Description:$0This error message appears when you try to execute an ALTER TABLE SWITCH command, for which column(s) in the source and table table have different datatypes.$0$0Consequences:$0The T-SQL statement can be parsed, but causes the error at runtime.$0$0Resolution:$0Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. All column(s) in the source and target table must have the same datatype.$0$0Versions:$0This error message was introduced with SQL Server 2005.$0$0Example(s):$0USE Pubs$0GO$0CREATE PARTITION FUNCTION myPartFunction (int)$0AS RANGE LEFT FOR VALUES (1, 10, 100);$0GO$0$0CREATE PARTITION SCHEME myPartScheme$0AS PARTITION myPartFunction$0ALL TO ([PRIMARY]);$0GO$0$0CREATE TABLE myPartTable$0($0c1 int$0)$0ON myPartScheme (c1);$0$0GO$0CREATE TABLE myNonPartTable $0($0c1 bigint$0)$0ON [PRIMARY];$0GO$0ALTER TABLE myPartTable SWITCH PARTITION 1 TO dbo.myNonPartTable ;$0GO$0$0DROP TABLE myNonPartTable, myPartTable;$0DROP PARTITION SCHEME myPartScheme;$0DROP PARTITION FUNCTION myPartFunction;$0$0Remarks:$0In the above example we try to execute an ALTER TABLE SWITCH command. Because the columns in the source and target table do haev different datatypes, the error is raised.$0



Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |