sql server - INSERT INTO/SELECT ONLY INSERTS ONE ROW -
i having problem sql insert into/select.
insert tblpmhistory(relequipmentid,dtethispmdue,strcampus,strroom) (select intequipmentid,dtepmdatenextdue,strcampus,strroom tblequipment dtepmdatenextdue between getdate() , dateadd("day",21,getdate()))
it seems insert 1 row new table, when run select part of statement on own, comes 84 rows.
i not sure if there limiting bulk insert or not appreciated.
the code create pmhistory table follows:
create table tblpmhistory( intpmhistoryid int not null primary key identity, relequipmentid int not null foreign key references tblequipment(intequipmentid), strdescription varchar(64) default 'preventative maintenance', dtethispmdue datetime, ysnpmdone bit default '0', ysnpmconvertedtojob bit default '0', intrelatedjobnumber int default '0', strcampus varchar(30), strroom varchar(30)) create unique nonclustered index [ix_pmhistory_dtethispmdue] on tblpmhistory( dtethispmdue) (ignore_dup_key = on) on [primary]
probably have constraints in table tblpmhistory such dtethispmdue can't null , select may contain null values column. doesn't have column, can other columns in destination table. should check invalid records in source table.
Comments
Post a Comment