with Store_Master (project_id,      
region_id,region,state_id,state,city_id,city,cpm_city_id,channel_id,channel,distributor_id,distributor_name, keyaccount_id, keyaccount,
insight_store_id,client_store_code,latitude,longitude,store_category_id,store_category,store_type_id,store_type,store_classification_id,store_classification, StLayerFourId,     
store_id,store_name,address)  
    AS (
select '40148',RegionId,RegionName,StateId,StateName,CityId,      
CityName,CityCode,ChannelId,ChannelName,DistributorId,Distributor,ChainId,ChainName,StoreUniqueCode,StoreCode,Latitude,      
Longitude, StoreCategoryId,StoreCategory,StoreTypeId,      
StoreType,StoreClassId,StoreClass,StLayerFourId,StoreId,      
StoreName,Address from OneApp_KelloggsMT.dbo.vw_storedetail where 1=1  
--and storeid not in (      
--select store_id from Store_Master where project_id='40148') 
)
select  *  from Store_Master 