Question : trying out an UNION in SQL.....need assistance

trying to write a query that uses an UNION of two tables to produce a third table...

Here is what I have so far:


if exists (select * from dbo.mydatabase where id = OBJECT_ID(N'[dbo]. [new_table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[new_table]
GO

select * into new_table from
(select EEO_1CLASSIFICATION,job_title_id from employees
union
select EEO_1_CLASSIFICATION,JOB_TITLE_ID from jobtitle)
A


This generates......Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.mydatabase'.
Msg 2714, Level 16, State 6, Line 2
There is already an object named 'new_table' in the database.


ANy help would be greatly appreciated.....

Answer : trying out an UNION in SQL.....need assistance

Delete this

if exists (select * from dbo.mydatabase where id = OBJECT_ID(N'[dbo]. [new_table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[new_table]
GO

Add this

if object_id('dbo.new_table') is not null
drop table [dbo].[new_table]
GO
Random Solutions  
 
programming4us programming4us