SQL server equivalent

experts.. I have to migrate an old sybase database in windows to sql server 2008. There is a function called TRUNCNUM in sybase. Is there an equivalent function in sql server 2008. If not, how do I convert this code to work in sql server 2008

SET @LoanToValue =  TRUNCNUM((((@LoanAmount + @LoanSubFinAmountCommon ) / @MinAmount)  + 0.0009),
                                  @LTVSignificantDigitsCalc) ;
Who is Participating?
Paul JacksonConnect With a Mentor Software EngineerCommented:
Round works fine as a replacement as long as @LTVSignificantDigitsCalc is always a positive number.
what does TRUNCNUM do?  
Paul JacksonSoftware EngineerCommented:
SET @LoanToValue =  ROUND((((@LoanAmount + @LoanSubFinAmountCommon ) / @MinAmount)  + 0.0009),
                                  @LTVSignificantDigitsCalc) ;
Lee SavidgeCommented:
TRUNCNUM (numeric-expression, integer-expression)
Truncates a number at a specified number of places after the decimal point.

Sybase ASA example:
truncnum ( 655, -2 )
truncnum ( 655.348, 2 )

In SQL Server, use the following CASE construction. Also you can implement this function as a user-defined function.

SQL Server example:
 WHEN 655>=0 THEN
  FLOOR(655*power(CAST(10 AS float), -2))/power(CAST(10 AS float), -2)
  CEILING(655*power(CAST(10 AS float), -2))/power(CAST(10 AS float), -2)

 WHEN 655.348>=0 THEN
  FLOOR(655.348*power(CAST(10 AS float), 2))/power(CAST(10 AS float), 2)
  CEILING(655.348*power(CAST(10 AS float), 2))/power(CAST(10 AS float), 2)

From: http://download.microsoft.com/download/7/C/2/7C20B070-BFF8-44B4-BD7D-1B03DF50F924/MigrateSybaseASAtoSQLServer2008.docx
Alpesh PatelAssistant ConsultantCommented:
Round is in SQL Server instead of TRUNCNUM
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.

All Courses

From novice to tech pro — start learning today.