Advertisement
elena1234

Create Function with % ( T-SQL)

Mar 27th, 2022
1,496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.30 KB | None | 0 0
  1. CREATE FUNCTION dbo.ufnReturnPercentOfNumber(@FirstNumber INT, @SecondNumber INT)
  2. RETURNS NVARCHAR(8)
  3. AS  
  4. BEGIN
  5.     DECLARE @Result DECIMAL(8,2) = (@FirstNumber * 1.0) / (@SecondNumber * 1.0) * 100.0
  6.     DECLARE @FinalResult NVARCHAR(8) = Cast(@Result AS NVARCHAR) + '%'
  7.     RETURN @FinalResult
  8. END
  9.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement