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 proc case question

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2007-02-21 : 16:01:47
How can i write, if statement if @modulename='CU'.....

**********************
Create PROCEDURE [dbo].[USP_SendEmailActionsSUM1]
(@ModuleID int,
@ModuleName nvarchar(50))
AS
if @Modulename='CU' then
Select * from table1 where moduleid=@moduleid
end if

************************

Thank you very much for the information.

ProEdge
Yak Posting Veteran

64 Posts

Posted - 2007-02-21 : 16:04:03
Remove the "then" and "end if". They're not used in if statements in SQL. So it should look like this.
Create PROCEDURE [dbo].[USP_SendEmailActionsSUM1]
(@ModuleID int,
@ModuleName nvarchar(50))
AS
if @Modulename='CU'
Select * from table1 where moduleid=@moduleid
Go to Top of Page

reddymade
Posting Yak Master

165 Posts

Posted - 2007-02-21 : 16:19:51
Thank you ProEdge, Can i use the following after if statement,
set @sqlstatement =

*************************************************************
Create PROCEDURE [dbo].[USP_SendEmailActionsSUM1]
(@ModuleID int,
@ModuleName nvarchar(50))
AS
if @Modulename='CU'
set @sqlstatement = 'Select * from table1 where moduleid ='+ convert(nvarchar(50), @ModuleID)=@moduleid

quote:
Originally posted by ProEdge

Remove the "then" and "end if". They're not used in if statements in SQL. So it should look like this.
Create PROCEDURE [dbo].[USP_SendEmailActionsSUM1]
(@ModuleID int,
@ModuleName nvarchar(50))
AS
if @Modulename='CU'
Select * from table1 where moduleid=@moduleid


Go to Top of Page

ProEdge
Yak Posting Veteran

64 Posts

Posted - 2007-02-22 : 11:06:26
Yes you should be able to. Try it out.
Go to Top of Page

reddymade
Posting Yak Master

165 Posts

Posted - 2007-02-22 : 11:51:22
Thank you Proedge, i tried yesterday and it worked fine.


quote:
Originally posted by ProEdge

Yes you should be able to. Try it out.

Go to Top of Page
   

- Advertisement -