Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
When iam executing this query am getting error....
insert into Tbl_Replace_Doc
select 50349+ROW_NUMBER() over(order by sh.code) ,
sd.C_Code,sd.C_Name,1,sh.grad,sd.C_Qualification,sd.C_Add_1,sd.C_Add_2,sd.C_Add_3,sd.C_Add_4,
sd.C_Pin,sd.C_Phone,sd.C_Fax,sd.C_Category,sd.C_Area_Code,sd.C_Subarea_Code,sd.D_DOB,
sd.D_DOW,sd.C_Email_ID,sd.C_FsCode,GETDATE(),0,'',null,0,GETDATE(),null,null,
sd.c_region_code,cd.c_div_code,sd.C_Doc_Class,null,null,sd.n_mcino,sd.C_FName,sd.C_LName
from sht sh
join Tbl_Doc_Stock_Chem_Add_Mst sd on sd.C_Code=sh.code
join Tbl_Cust_Div cd on cd.c_cust_code=sd.C_Code


error i have mentioned in below

Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'Tbl_Replace_Doc' can only be specified when a column list is used and IDENTITY_INSERT is ON

please give solution for this am waiting
Posted
Comments
Thanks7872 11-May-15 3:26am    
You have set some column to identity so you should not insert values in that column. Search google for what is IDENTITY_INSERT ON.

1 solution

If you Declare column with Identity.You don't need to Insert value for that column.value will b automatically inserted based on values inserted on other columns


If u try u inserted Value to that identity Column ,u get that error as u encountered.

If u need to insert value explicitly u need to SET IDENTITY_INSERT TABLENAME ON
and u can start inserting values to that column.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900