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 |
rssrk
Starting Member
9 Posts |
Posted - 2013-08-23 : 05:37:56
|
i am creating a function named as drcr which returns value as varchar.now the condition is like that-if number is positive then result should be like that dr(135)=135(cr)if number is negative then result should be like that dr(-25)= 25(dr)i had created function of drcr which returns value as varcharnow can i get code for the above condition ??create function drcr(@text nvarchar(140)) returns varcharas begin |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-23 : 06:36:18
|
what is dr/cr here.. I'm not getting your point... Can you explain in detail..What type of data you will pass? You can check for -ve/+ve values by using SIGN(expression) functionFor negative values, SIGN returns -1For positive values, SIGN returns 1--Chandu |
|
|
rssrk
Starting Member
9 Posts |
Posted - 2013-08-23 : 08:35:00
|
create function [dbo].[drcr](@n float)returns nvarchar(20)as begin if(@n>0) return CONVERT(nvarchar(20),@n)+' (cr)' return CONVERT(nvarchar(20),@n*(-1))+' (dr)'endGOthat was the code i was asking for...btw query is solved and thanx once again :) |
|
|
|
|
|