Advertisement

01.19.2008 at 08:44AM PST, ID: 23095758
[x]
Attachment Details

union all returned table from loop

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4
Tags:

sql server express 2005

Hi,

I have a stored procedure that suppost to return tables by a loop, for searching inside sql table by multiple keywords. How I make all these returned tables return as one table with all of the rows in each one unioned?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
ALTER PROCEDURE [dbo].[qry_show_bids_for_thumbs_acc_by_text]
	@KEYWORDS VARCHAR(100)
AS
BEGIN
	SET NOCOUNT ON;
 
	DECLARE @KeyResults TABLE ( myKey varchar(50) )
 
	INSERT INTO @KeyResults (myKey)
	(select * from fnSplit(@KEYWORDS, ' '))
 
	DECLARE @myint int
	DECLARE @currKey varchar(50)
	DECLARE @myclause varchar(max)
 
	set @myint = 0
 
	while @myint <= (select count(*) from @KeyResults)
	begin
		set @currKey = (SELECT myKey FROM (SELECT Row_Number() OVER (ORDER BY myKey) as rowid, myKey FROM @KeyResults ) as a where rowid = @myint)
		set @myint=@myint+1
		
		SELECT        tbl_bids.bid_id
					, tbl_accessories.acc_name
					, tbl_accessories.acc_description
					, MAX(tbl_gallery.gallery_imageurl) AS FirstOfgallery_imageurl
					, MAX(tbl_gallery.gallery_alt) AS FirstOfgallery_alt
					, tbl_bids.bid_enddate
					, tbl_bids.bid_prodtype
					, tbl_bids.bid_minprice
		FROM	tbl_accessories WITH (NOLOCK) INNER JOIN 
				tbl_bids WITH (NOLOCK) ON tbl_accessories.acc_id = tbl_bids.bid_accid LEFT JOIN
				tbl_gallery WITH (NOLOCK) ON tbl_accessories.acc_id = tbl_gallery.gallery_accid
				WHERE tbl_accessories.acc_name LIKE '%' + @currKey + '%'
		GROUP BY  tbl_bids.bid_id
				, tbl_accessories.acc_name
				, tbl_accessories.acc_description
				, tbl_bids.bid_enddate
				, tbl_bids.bid_prodtype
				, tbl_bids.bid_minprice
		HAVING ((tbl_bids.bid_enddate>=getdate()) AND (tbl_bids.bid_prodtype='Other'))
	end
END
 
Accepted Solution by dtodd:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by sagir:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Administrative Comment by BrandonGalderisi:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Administrative Comment by Computer101:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-45 / EE_QW_2_20070628