Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Query stored in database

Status
Not open for further replies.

raynkel

Programmer
Oct 24, 2002
23
US
I store a query String..ie(Select * From Project, etc) in a database as a record. I want to call that query string and run it. I will send it the Record number and need to get back the results of the querystring that is in the database.

I could just do one call to get the string and then use that result to run another query, but that seems wasteful.
Any suggestions?
 
I am not sure how to set it up to do it. How do I run a QueryString that is stored as a record?
 
--This works

SET ANSI_NULLS ON
SET ANSI_WARNINGS OFF
go
CREATE PROCEDURE [dbo].[sp_GetQueryResults]
@ReportNumber int
as
DECLARE @String varchar(8000)
SET @string = (SELECT QueryString FROM ReportQuerys where reportid = @ReportNumber)
exec (@string)
GO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top