March 9, 2015 at 11:05 am
I have the following table where I store the QuerystringTBL
QueryString, MatchId
-----------------------------
CodeValue between 1 and 100
DateValue >= '01/01/2015'
I want to get the querystring in one string something like
@strWHERE = CodeValue between 1 and 100 and DateValue >= '01/01/2015'
Is it possible using a CTE? I can do this using a while loop but since that is not an efficient code I wanted to use CTE. I have the following then after that I am stuck.
WITH CTE_query (query)
AS
(
SELECT Query from QueryStringTBL where matchId = 1
)
March 9, 2015 at 11:51 am
Guras (3/9/2015)
I have the following table where I store the QuerystringTBLQueryString, MatchId
-----------------------------
CodeValue between 1 and 100
DateValue >= '01/01/2015'
I want to get the querystring in one string something like
@strWHERE = CodeValue between 1 and 100 and DateValue >= '01/01/2015'
Is it possible using a CTE? I can do this using a while loop but since that is not an efficient code I wanted to use CTE. I have the following then after that I am stuck.
WITH CTE_query (query)
AS
(
SELECT Query from QueryStringTBL where matchId = 1
)
I guess I don't understand the question. If I'm reading it correctly, you don't need a loop or a CTE. If I'm not reading it correctly, is it that you want to generate the values of 1 to 100 for CodeValue?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 9, 2015 at 11:54 am
No. I am building the where clause based on the rows for matchId 1 from the table. I want all the matching rows concatenated to a string as the result set.
Thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply