Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

SWITCH Command in Sql Server 2005

Avatar of dev2dev
dev2devFlag for India asked on
Microsoft SQL Server 2005
15 Comments1 Solution1207 ViewsLast Modified:

I am trying to switch a non-partitioned table's data to a partitioned table. I am getting this error




Msg 4982, Level 16, State 1, Line 1

ALTER TABLE SWITCH statement failed. Check constraints of source table 'NON_PARTITIONED_TABLE' allow values that are not allowed by range defined by partition 4 on target table 'PARTITIONED_TABLE'.


(Tables names or dummy, not actual names)
Non-Paritioned table's structure matches exactly with the partitioned table
I copied table description using sp_help into excel of both tables and did comparision, which is matching 100% (column names, data types, null ability and so on,indexes)
In fact, we have a stored procedure which clones partitioned table using schema_information views (that way it matches 100%)
Only 1 difference is that filegroup is different, I think this doesn't matter, or am I wrong?

Please help me to understand where and what is going wrong?

Additional info: ETL flow
Create Partition
Create FileGroup and Files
Clone all existing tables with a prefix TMP_ on newly created FileGroup
BCP into newly created TMP_ tables
Create indexes on TMP_ (so that to table structure's match 100% which enables switching)
Switch tables --- And here is the error I get
Drop TMP_ tables

Avatar of ProjectChampion
ProjectChampionFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answers