如何使用Select语句将查询出来的数据存储为一个临时表 create view #vieCount
as
SELECT fTaskID,
(SELECT COUNT(*) AS Expr1
FROM dbo.tblFeedback
WHERE (fTaskID = dbo.tblTask.fTaskID) AND (fAnswerContent IS NULL)) AS Count
FROM dbo.tblTask
go
SELECT a.* into #表名 from (SELECT fTaskID,
(SELECT COUNT(*) AS Expr1
FROM dbo.tblFeedback
WHERE (fTaskID = dbo.tblTask.fTaskID) AND (fAnswerContent IS NULL)) AS Count
FROM dbo.tblTask) a
------解决方案--------------------
但是觉得你这个写法看上去怪怪的。你执行的时候难道不报语法错误?
那你就试试这样吧
SELECT fTaskID,
(
SELECT COUNT(*) AS Expr1 FROM dbo.tblFeedback
WHERE (fTaskID = dbo.tblTask.fTaskID) AND (fAnswerContent IS NULL)
) AS Count
into #abc
FROM dbo.tblTask