Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

pass where clause to stored procedure for cursor

Posted on 2004-10-31
1
Medium Priority
?
357 Views
Last Modified: 2006-11-17
Is it possible?
something like that

DECLARE C  CURSOR FOR SELECT * FROM TABLE WHERE @WHERE_CLAUSE
0
Comment
Question by:kako
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
BillAn1 earned 500 total points
ID: 12456237
if you want to do something like this you need to use dynamic SQL

declare @MySQL varchar(1000)
set @MySQL = 'DECLARE C  CURSOR FOR SELECT * FROM TABLE WHERE ' + @WHERE_CLAUSE
exec (@MySQL)

just beware of the potential security risk here , particularly if @WHERE_CLAUSE is passed in as a parameter.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question