2016-10-18 1 views
1

私は条件を実行しているときに、その時点でテーブルにデータを挿入しています。つまり、SQL Serverの "マルチパート識別子が見つかりません"というエラーが表示されます複数の部分の識別子がsqlserverに見つかりませんでした

ここで

は、あなたが正しいが、これに参加するが、ここでは上記のクエリへのソリューションです置くべき私のクエリ

SELECT CASE 

      WHEN p.id = tmp.ProductId and p.Deleted = 0 and p.Published = 1 and p.VisibleIndividually = 1 
       THEN 

     Insert into mysql_abc_Product(ProductId, abcStatus, IsDeleted, InTime, StoreId,LanguageId) 
     select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id 
     where isp.Id is NULL and p.Deleted = 'False' or p.Published = 'True' or VisibleIndividually = 'True' 

       ELSE 

     Insert into mysql_abc_Product(ProductId, abcStatus, IsDeleted, InTime, StoreId,LanguageId) 
     select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id 
     where isp.Id is NULL and p.Deleted = 'True' or p.Published = 'False' or VisibleIndividually = 'False' 

     END as Saleable, * 
FROM Language l, Store s, Product p left outer join #temp tmp on tmp.productid = p.Id where isp.Id is NULL 
+2

*絶対に* FROM句にカンマを使用しないでください。 *常に*適切な明示的な 'JOIN'構文を使用してください。この場合、問題を解決するはずです。 –

+0

そうですね。しかし、結合構文を使用することによっても同じ問題が発生します。 – karan

+0

最後の行のWhere句にisp.Idがありますが、From文にispで修飾されたテーブルはありません。 –

答えて

1

です。最後の行From文に "isp"で修飾されたテーブル "Incremental_Solr_Product"を含めなかった。

SELECT CASE 

      WHEN p.id = tmp.ProductId and p.Deleted = 0 and p.Published = 1 and p.VisibleIndividually = 1 
       THEN 

     Insert into Incremental_Solr_Product(ProductId, SolrStatus, IsDeleted, InTime, StoreId,LanguageId) 
     select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id 
     where isp.Id is NULL and p.Deleted = 'False' or p.Published = 'True' or VisibleIndividually = 'True' 

       ELSE 

     Insert into Incremental_Solr_Product(ProductId, SolrStatus, IsDeleted, InTime, StoreId,LanguageId) 
     select DISTINCT tmp.ProductId,1,0,GETDATE(),s.Id,l.Id from Language l, Store s, #temp tmp, Product p left join Incremental_Solr_Product isp on isp.ProductId = p.Id 
     where isp.Id is NULL and p.Deleted = 'True' or p.Published = 'False' or VisibleIndividually = 'False' 

     END as Saleable, * 
FROM Language l, Store s, Product p left outer join #temp tmp on tmp.productid = p.Id 
left join Incremental_Solr_Product isp on isp.ProductId = p.Id 
where isp.Id is NULL 
関連する問題