You need to declare @strSql before you write "as begin", 
otherwise you have written right flow with wrong logic

@strSql is a variable varchar type 
so when u write 
 @strSql= @strSql + "Something"

u need to write this way
 @strSql= @strSql + (Select  varcharfield1  from  vm_property where 
propertyId=1)
 
N.B
if the datatype is not varchar, u need to convert that.  
now ur @strSql is ready .

do whatever u want .

Cheers
Arindam

imane elfechtani <[EMAIL PROTECTED]> wrote:
Hello,

I was wondering, can we have a stored procedure with a divided query? 
I have tried the following, and it doesn't seem to work:

create procedure mimo (@id varchar)
as begin
declare @strSql varchar
set @strSql = (select * from vm_property) 
IF @id = 1
begin 
set @strSql = @strSql + 'where vm_property.propertyId=1' 
End 
ELSE 
begin 
set @strSql = @strSql + 'where vm_property.propertyId=4'
Go

Thank 

Imane


---------------------------------
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.

[Non-text portions of this message have been removed]




Yahoo! Groups Links










Thanks & Regards

Arindam 
Web Designer & Developer  




Yahoo! India Matrimony: Find your life partneronline.

[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to