Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql server union if table exist

DECLARE @temp TABLE(empName varchar(100),empStoreNum varchar(100),empSales int,location varchar(20))
if object_id('table1') Is not null
insert into @temp
Select empName, empStoreNum, empSales, 'East' As SalesDistrict
FROM store1

if object_id('table2') is not null
insert into @temp
Select empName, empStoreNum, empSales, 'East' As SalesDistrict
FROM store2

if object_id('table3') is not null
insert into @temp
Select empName, empStoreNum, empSales, 'East' As SalesDistrict
FROM store3


select empName, empStoreNum, empSales,location
from @temp
Comment

PREVIOUS NEXT
Code Example
Sql :: in sql developer where equal queres 
Sql :: datatype for phone number in sql 
Sql :: error E11000 
Sql :: ORA-32794: cannot drop a system-generated sequence 
Sql :: the primary key is selected from the 
Sql :: mysql docker image arjun 
Sql :: graphql return x item 
Sql :: ora 00001 in oracle 
Sql :: nosql databases 
Sql :: SQL server datetime compare 
Sql :: subquery in Delete 
Sql :: postgresql auto increment not working 
Sql :: count with where 
Sql :: list databases in sql server 
Sql :: bigquery function 
Sql :: sql replace id with name from another table 
Sql :: how to select the lowest values from table per client sql 
Sql :: how to retrive image from sql to picturebox usinf image location 
Csharp :: how to restart a scene in unity 
Csharp :: unity cycle children 
Csharp :: Changing datagridview cell color dynamically 
Csharp :: camera follow 
Csharp :: how t remove a component in unity 
Csharp :: unity to integer 
Csharp :: unity coroutine 
Csharp :: c# get all inherited classes of a class 
Csharp :: c# get last character of string 
Csharp :: c# int to bool 
Csharp :: c# summary link 
Csharp :: remove all non number in c# 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =