首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql2008 点击表insert时插入其他表数据提示如下异常

2013-06-25 
sql2008 点击表insert时插入其他表数据提示如下错误代码如下:INSERT INTO [ExamV2.0].[dbo].[GSys_Doctors

sql2008 点击表insert时插入其他表数据提示如下错误
sql2008 点击表insert时插入其他表数据提示如下异常

代码如下:
INSERT INTO [ExamV2.0].[dbo].[GSys_Doctors]
           ([CD_SerialCode]
           ,[CD_DoctorName]
           ,[CD_Gender]
           ,[CD_JobTitle]
           ,[CD_SeniorityCode]
           ,[CD_PracticeCode]
           ,[CD_MedicCode]
           ,[CD_IndentityCode]
           ,[CD_CatalogCode]
           ,[CD_State])
     VALUES
       [cmda_drems].[dbo].[GSys_Doctors]        
           ([CD_SerialCode]
           ,[CD_DoctorName]
           ,[CD_Gender]
             ,[CD_JobTitle]
            , '1111111'
            ,'1111111'
           ,[CD_MedicCode]
           ,[CD_IndentityCode]           
             ,[CD_MedicSort] 
             ,'1')
GO

[解决办法]
那就要改成这样

INSERT  INTO [ExamV2.0].[dbo].[GSys_Doctors] 
        ( [CD_SerialCode] , 
          [CD_DoctorName] , 
          [CD_Gender] , 
          [CD_JobTitle] , 
          [CD_SeniorityCode] , 
          [CD_PracticeCode] , 
          [CD_MedicCode] , 
          [CD_IndentityCode] , 
          [CD_CatalogCode] , 
          [CD_State] 
        ) 
select  [CD_SerialCode] , 
          [CD_DoctorName] , 
          [CD_Gender] , 


          [CD_JobTitle] , 
          '1111111' , 
          '1111111' , 
          [CD_MedicCode] , 
          [CD_IndentityCode] , 
          [CD_MedicSort] , 
          '1'
from  [cmda_drems].[dbo].[GSys_Doctors]

        
[解决办法]
try this,

INSERT INTO [ExamV2.0].[dbo].[GSys_Doctors]
           ([CD_SerialCode]
           ,[CD_DoctorName]
           ,[CD_Gender]
           ,[CD_JobTitle]
           ,[CD_SeniorityCode]
           ,[CD_PracticeCode]
           ,[CD_MedicCode]
           ,[CD_IndentityCode]
           ,[CD_CatalogCode]
           ,[CD_State])
select [CD_SerialCode]
       ,[CD_DoctorName]
       ,[CD_Gender]
       ,[CD_JobTitle]
       ,'1111111'
       ,'1111111'
       ,[CD_MedicCode]
       ,[CD_IndentityCode]           
       ,[CD_MedicSort] 
       ,'1'
from [cmda_drems].[dbo].[GSys_Doctors]

热点排行