儘管實現我收到錯誤的過程:存儲過程給錯誤而實施
消息156,級別15,狀態1,過程GET_USER_REPORT_DATA,行中的關鍵字19
附近有語法錯誤選擇「。Msg 102,Level 15,State 1,Procedure GET_USER_REPORT_DATA,Line 23
')'附近的語法不正確。
下面是該過程
ALTER PROCEDURE [dbo].[GET_USER_REPORT_DATA]
@From_Date datetime,
@To_Date datetime
AS
BEGIN
Select *
into #GetUserTable
from
(select distinct
a.N_UserMkey, b.mkey,
ISNULL(b.first_name + ' ' , '') + ISNULL(b.last_name,'') NAME
from
inward_doc_tracking_trl AS a
inner join
user_mst AS b on a.N_UserMkey = b.mkey
where
a.U_datetime between @From_Date and @To_Date
select distinct
a.mkey, b.ref_mkey
from
inward_doc_tracking_hdr AS a
inner join
inward_doc_tracking_trl AS b on a.mkey = b.ref_mkey
and a.U_datetime between @From_Date and @To_Date
) as xx
SELECT * FROM #GetUserTable
DROP TABLE #GetUserTable
END
我想你可能忘了把工會或聯合之間兩個喲你在內部查詢中選擇語句 – navnit
@navnit:我已經嘗試過使用'union',但它詢問'所有使用UNION,INTERSECT或EXCEPT操作符組合的查詢必須在其目標列表中具有相同數量的表達式「 – BNN
查詢返回三個字段,第二個查詢返回兩個字段。如果你想使用union – navnit