Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
qutesanju
Posting Yak Master
193 Posts |
Posted - 2009-07-20 : 11:35:08
|
| hi allI'm getting an error while collection from few of SQL as belowI want to collect count from few below SQL into one TEMP tableI'm getting an error as ----Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.================================================================select (select 'KC_PROD_SUM',count (*)from (SELECT * FROM [KC_PROD_SUM] where [KC_PROD_SUM_MES_PRODU_DATE_DT] <= getdate() ) A---------------------------------------------------------------------------------------------union all---------------------------------------------------------------------------------------------select 'KC_PROD_WASTE',Count(*)from (SELECT * FROM [KC_PROD_WASTE]where [KC_PROD_WASTE_MES_PRODU_DATE_D] <= getdate()) as B) as inlineinto #DataPurgeCountTable================================================================ |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-07-20 : 11:53:23
|
| select desc, cnt into #DataPurgeCountTablefrom (select 'KC_PROD_SUM' as desc,count (*) as cntfrom (SELECT *FROM [KC_PROD_SUM]where [KC_PROD_SUM_MES_PRODU_DATE_DT] <= getdate() ) A---------------------------------------------------------------------------------------------union all---------------------------------------------------------------------------------------------select 'KC_PROD_WASTE' as desc,Count(*) as cntfrom (SELECT *FROM [KC_PROD_WASTE]where [KC_PROD_WASTE_MES_PRODU_DATE_D] <= getdate()) as B) as inline |
 |
|
|
|
|
|