472,144 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

Need help executing saved SQL syntax on the fly

Hi all,
I am new to programming....but here goes. I am using ASP, SQL Server 2000 database on a shared server environment & IIS 6.0.

I have a table called USER_SEARCH, within that table is a field called SEARCH_QUERY containing saved search SQL syntax from saved user searches. Examples of exact saved syntax in the field is shown below:

select * from [user] where (birth_year <= 1975) and (birth_year >= 1910) and (Gender='Male' and Gender_look='Female') and (active=1) and (enabled=1) order by last_active desc


select * from [user] where (Height_Feet+(Height_Inch/12) >= 4) and (Height_Feet+(Height_Inch/12) <= 7) and (Photo is not null) and (birth_year <= 1978) and (birth_year >= 1968) and (Gender='Female' and Gender_look='Male') and (active=1) and (enabled=1) order by last_active desc


What I am trying to code in ASP/VbScript is to be able pull out the SQL syntax as shown above, one record at a time, execute it against the [USER] table (where all the user information resides), put the result in a recordset ( so I can eventually email the query results to the user)

I am stuck.....I tried below code, but the results are only the SQL syntax code being pulled into recordset not the actual data/results of the actual query

sql = "select search_query from user_search where search_id=" & search_id
set rsQ = conn.execute(sql)
if not rsQ.eof then

>>>>>>Execute the SQL SYNTAX found in rsQ against table [USER]
>>>>Put the results in a recordset- ( so i can email the results to the user)


Loop
end if
rsQ.close
set rsQ = nothing


Can you guys give some pointers on the area with >>>>>>
I am trying to execute stored SQL syntax on the fly....it should be possible.

Thanks
Henry B.
Mar 2 '07 #1
0 1104

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Chris Reedy | last post: by
35 posts views Thread by Boobie | last post: by
46 posts views Thread by Bruce W. Darby | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.