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.
| 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))ASif @Modulename='CU' then Select * from table1 where moduleid=@moduleidend 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))ASif @Modulename='CU'Select * from table1 where moduleid=@moduleid |
 |
|
|
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))ASif @Modulename='CU'set @sqlstatement = 'Select * from table1 where moduleid ='+ convert(nvarchar(50), @ModuleID)=@moduleidquote: 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))ASif @Modulename='CU'Select * from table1 where moduleid=@moduleid
|
 |
|
|
ProEdge
Yak Posting Veteran
64 Posts |
Posted - 2007-02-22 : 11:06:26
|
| Yes you should be able to. Try it out. |
 |
|
|
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.
|
 |
|
|
|
|
|