views:

46

answers:

2

I am simply taking the data from a Table and insert it into #tempTable then delete the data, and insert it back to the table. I get "Insert Error: Column name or number of supplied values does not match table definition." Error.

Here are the lines I am running.

SELECT * INTO #tempTable FROM dbo.ProductSales

SELECT * FROM #tempTable

DELETE FROM dbo.ProductSales

INSERT INTO dbo.ProductSales SELECT * FROM #tempTable

Any Idea?

+1  A: 

If ProductSales has an identity or timestamp/rowversion column you will not be able to use SELECT * to do an insert. Instead, enumerate the columns skipping the identity column:

Insert ProductSales(Col1, Col2....
Select Col1, Col2...
From #tempTable
Thomas
A: 

Thanks for the quick response. It was because ProductSales has a computed(Calculated) column. So I had to choose the column names one at a time like Thomas suggested.

Thanks, AJ

AJ JIM
You should "accept" Thomas's answer...
egrunin