--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;
-- 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;
No comments:
Post a Comment