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)
 Where Cluase dynamically in procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-06-21 : 06:33:45
saurabh writes "Dear Sir

I want to put the where clause dynamically in @whereClause
in Select Statemant .
There is any mistake any below clause ,
Please Suggest.


As Below

Create proc uspTesting
(
@WHERECLAUSE NVARCHAR(4000)
)


AS

Select * from table where = @whereclause

Please do the Needful as early as possible,
i will be varr gratful .

Thnxs and Regards
Saurabh "

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-21 : 06:53:46
[code]

Create proc uspTesting
(
@WHERECLAUSE NVARCHAR(4000)
)
AS
Exec('Select * from table where '+@WHERECLAUSE )
[/code]
But it is better to pass parameters and build query inside sp than combining all

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -