Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1===================================================================
--i have not created the #facility table
--but if i execute the below statement
select facility_id,Facility_Name into #facility from tbl_facility where hub=1

it successfully inserts....

2==========================================================================
---but if i do like this--i am not creating #facility table


select facility_id,Facility_Name from tbl_facility where hub=1
union all
select facility_id,facility_name from tbl_facility where facility_id=145
into #facility4

--it gives me error
--Incorrect syntax near the keyword 'into'.

3=====================================================================

--and if i do like this--i am not creating #facility table


select facility_id,Facility_Name into #facility5 from tbl_facility where hub=1
union all
select facility_id,facility_name into #facility5 from tbl_facility where facility_id=145

There is already an object named '#facility5' in the database.

--i changed it to #facility6 ..same error....
i am pondering over it....why this error is coming...if step 1 works fine,,,
then step 2 or 3 should also work fine,,,,
Posted
Updated 27-Jun-13 6:39am
v2
Comments
CHill60 27-Jun-13 14:39pm    
Please don't repost what is essentially the same question. You can use the "Improve question" link to add details to a question
anurag19289 27-Jun-13 14:45pm    
yes but here i have posted because,,, i didnot want to make it more clumsy there,,,,,anyways thanks
anurag19289 27-Jun-13 14:48pm    
and also i want to know why the error is there in 2nd point,,,,please help

1 solution

Try

SQL
select facility_id,Facility_Name into #facility5 from tbl_facility where hub=1
union all
select facility_id,facility_name from tbl_facility where facility_id=145
 
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