Sunday, November 10, 2019

SMS Count Function

--SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;   
   
-- SELECT dbo.CountSMS('HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF HELLOJINIENENENENEE E E E E E  E EJENJDNEJDNE E EJDNENEF E EJNEF')   
CREATE FUNCTION CountSMS(@StringName nvarchar(1000))   
RETURNS int   
AS   
BEGIN   
--Declare @StringName nvarchar(50);   
Declare @initialLen int;   
Declare @WithFraction decimal(18,2);   
Declare @WithoutFraction int; 
Declare @smsCount int;   
   
SET @WithFraction = 0.00;   
SET @smsCount = 1;   
   
SET @initialLen = (SELECT len(@StringName));   
   
SET @WithFraction = @initialLen / 70.00;   
SET @WithoutFraction = @WithFraction 
   
IF(@WithFraction > @WithoutFraction)   --(@WithFraction < 1.00 AND @WithFraction > 0.00)   
BEGIN   
SET @smsCount = @WithoutFraction + 1;   
END   
ELSE   
BEGIN   
SET @smsCount = ROUND(@WithFraction,0);   
END   
   
   
   RETURN @smsCount   
   
 END   
   
-- SELECT SUBSTRING('SQL Tutorial', 1,1) AS ExtractString;

Monday, November 4, 2019

SQL FUNCTION Convert Numeric value to bangla.

--SELECT SUBSTRING('SQL Tutorial', 1, 100) AS ExtractString;

-- SELECT dbo.ConvertToBangla(12456.9087)
ALTER FUNCTION ConvertToBangla(@StringName nvarchar(50))
RETURNS NVARCHAR(50)
AS
BEGIN

--Declare @StringName nvarchar(50);
Declare @FinalString nvarchar(50);
Declare @FinalString2 nvarchar(50);

Declare @SingleCharacter nvarchar(1);
Declare @len int;
Declare @Templen int;

--SET @StringName = '8767564.89780';
SET @FinalString = N'';
SET @len = (SELECT LEN(@StringName));
SET @Templen = 1;
--SELECT @len

 WHILE @Templen <= @len
BEGIN
  SELECT @SingleCharacter = SUBSTRING(@StringName, @Templen,1)
 
    --SELECT  @SingleCharacter;
 
   SELECT @FinalString2 =
   CASE
    WHEN @SingleCharacter = '1' THEN N'১'
    WHEN @SingleCharacter = '2' THEN N'২'
    WHEN @SingleCharacter = '3' THEN N'৩'
WHEN @SingleCharacter = '4' THEN N'৪'
WHEN @SingleCharacter = '5' THEN N'৫'
WHEN @SingleCharacter = '6' THEN N'৬'
WHEN @SingleCharacter = '7' THEN N'৭'
WHEN @SingleCharacter = '8' THEN N'৮'
WHEN @SingleCharacter = '9' THEN N'৯'
WHEN @SingleCharacter = '0' THEN N'০'
WHEN @SingleCharacter = '.' THEN N'.'
    ELSE N''
END
--SELECT @FinalString2;

SET @FinalString = @FinalString + @FinalString2

SET @Templen = @Templen + 1;

END;

   --SELECT @FinalString;
   RETURN @FinalString
 
 END

-- SELECT SUBSTRING('SQL Tutorial', 1,1) AS ExtractString;

Screen Record

 Windows Screen Record WindowsKey+ Alt + R Recording Starts.