select facility_id,Facility_Name into #facility2 from tbl_facility where hub=1
that gives me some records.. like
facility_id facility_name
1 office1
2 office2
3 office3
and so on ,,,
all these facilityid has hub=1
-----------------------------------------
but i need to add one more office in #facility2 whose hub is not equal to 1
--------------------------------------
so i was tryig like this
1)
select facility_id,Facility_Name into #facility2 from tbl_facility where hub=1
union all 4,'office4'
--it gave me error -->Incorrect syntax near 4.
2)then i tried like this
select facility_id,Facility_Name into #facility2 from tbl_facility where hub=1
insert into #facility2 select facility_id,Facility_Name from tbl_facility where facility_id=236
--here office4 has facility_id=236 whose hub is not equal to 1,,,i tried like this.
--giving me error...
--An explicit value for the identity column in table '#facility2' can only be specified when a column list is used and IDENTITY_INSERT is ON.
3)
then i tried like this
select facility_id,Facility_Name into #facility2 from tbl_facility where hub=1
union all
select facility_id,Facility_Name into #facility2 from tbl_facility where facility_id=236
i got error
There is already an object named '#facility2' in the database.
how to solve this ?
4) then i tried like this ...
select facility_id,Facility_Name into #facility2 from tbl_facility where hub=1
insert into #facility2 values(4,'office4')
i got error
An explicit value for the identity column in table '#facility4' can only be specified when a column list is used and IDENTITY_INSERT is ON.
5) on my 5th attempt...i got the solution just now....
create table #facility2
(
facility_id int,
Facility_Name varchar(77)
)
insert into #facility2
select facility_id,Facility_Name from tbl_facility where hub=1
union all
select facility_id,facility_name from tbl_facility where facility_id=236
But doubt still persist,,,, why the above 4 attempts failed,,,,
Help me regarding this..