我正在嘗試使用SP獲取值。查詢如下。SQL查詢未獲取值
create proc [dbo].[GetOrdersByUserID11]
(
@UserID int
)
as
begin
declare @status varchar(1000)
set @status=' select a.*, b.CategoryText, Cast('''' as Varchar(10)) as SectionsViewed, PurchasedDate as dateadded into #myCourses1 from dbo.Tbl_CourseInformations a JOIN Tbl_Categories b ON a.AssignCategory = b.CategoryID '
set @[email protected]+' Join Tbl_Orders c ON c.UserID = '+convert(varchar(10),@UserID)+''
set @[email protected]+'Order By CategoryText, CourseTitle '
print @status
exec(@status)
select * from #myCourses1
end
This is message from my query when run my SP[[dbo].[GetOrdersByUserID11] 5085 ]:
select a.*, b.CategoryText, Cast('' as Varchar(10)) as SectionsViewed, PurchasedDate as dateadded into #myCourses1 from dbo.Tbl_CourseInformations a JOIN Tbl_Categories b ON a.AssignCategory = b.CategoryID Join Tbl_Orders c ON c.UserID = 5085
(99 row(s) affected)
我得到的消息99行受到影響,但在我的結果中只獲得帶有0(零)列的標題。
Plz確實幫助我獲得價值。
在此先感謝。
+1。它有時比第一次看起來更棘手 – 2011-05-16 14:02:55