Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 stored procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-04-20 : 08:33:19
dave writes "I'm calling some sp's on SQL Server 7 , from a visual basic program.

Here is the stored procedure:

CREATE PROCEDURE SelectWorkReq_Cond
@Field varchar(100),
@Condition varchar(100)

AS
DECLARE @sqlstr varchar(100)

BEGIN
SET @sqlstr = "SELECT WorkRequestID , Name , ProjType , StartDate, EndDate , ProjManager FROM dbo.WorkRequest WHERE ' + @Field + ' LIKE ' + @condition + ' + '%' "
EXEC (@sqlstr)
END

........
I'm passing 2 paramaters Field & Condition , where field could be 'Name'(the database field) and Condition could be 'F' , 'Fr' or 'Fred' etc , and should all give same result with LIKE word.
Currently when I run it , I just get a list of every record in the database.

Can some one take a look at my syntax , as i'm fairly sure theres something wrong there.
Any help much appreciated.
Thanks"
   

- Advertisement -