sql, if then else in stored procedure

Posted on 2013-01-14
Medium Priority
Last Modified: 2013-01-14
Hi All,

I'm trying to do the below and not so great at sql.  Can anyone help me with the following statement?

.  This will be in a stored procedure
same concept as if then else...  but i dont think it can be a case

This is my original.

UPDATE dbo.DailyPositions_JEFF
SET [P&L Settlement]= (((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])

Open in new window

I want to say...
If [Value 1Point] = 0.9999
do this
SET [p&L Settlement] =
[delta settlement] *
(1/[tick_size]) *[tick_value]
[local rate]

else.... do this

SET [P&L Settlement]= (((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])

thanks for all the help
Question by:solarissf
  • 2
LVL 32

Accepted Solution

Ephraim Wangoya earned 2000 total points
ID: 38774138
Case will still work, here

UPDATE dbo.DailyPositions_JEFF
SET [P&L Settlement] =
		when [Value 1Point] = 0.9999 then
			(((ISNULL([Delta Settlement],0)*[Value 1Point])*[Local Rate])*[Qty_Net])
			[delta settlement] * (1/[tick_size]) *[tick_value]*[local rate]

Open in new window


Author Comment

ID: 38774145
ahha.... I didnt know that... kinda looks like a iF ELSE anyway.
looks that this will work... thanks!!!  I'll try it out

Author Comment

ID: 38774532
worked... thank you!!!

another question in terms of performance and speed.

which is faster..
1.   to use the case ... else
2.  have the stored procedure call a scalar function
scalar function using pulled in paramaters will a true if else

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question