I had a table field named 'topicfull' code. Its type was varchar(50). I had some values as follows
Now I want to change the value of topicFullCode into arabic numbers. So I have changed the type of the table name using the following query.
ALTER TABLE TopicInfo
ALTER COLUMN topicFullCode NVARCHAR(50) null
Then create a function as follows:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[ReplaceIntegersWithArabicNumbers]
(
@str NVARCHAR(1000)
)
RETURNS NVARCHAR(2000)
AS BEGIN
DECLARE @newStr NVARCHAR(1000)
set @newStr= ''
declare @val NVARCHAR(1)
set @val = ''
declare @i INT
set @i = 1
WHILE @i<=LEN(@str)
BEGIN
SET @val = SUBSTRING(@str, @i, 1)
IF ((@val) >= '0' and (@val) <= '9')
BEGIN
SET @val =
CASE @val
WHEN 1 THEN N'۱'
WHEN 2 THEN N'۲'
WHEN 3 THEN N'۳'
WHEN 4 THEN N'٤'
WHEN 5 THEN N'۵'
WHEN 6 THEN N'٦'
WHEN 7 THEN N'۷'
WHEN 8 THEN N'۸'
WHEN 9 THEN N'۹'
WHEN 0 THEN N'۰'
END -- CASE
END -- IF
SET @newStr = (@newStr + @val)
SET @i=@i+1
END -- WHILE
RETURN @newStr
END
And execute the following query to replace the values.
UPDATE TopicInfo
SET topicFullCode = dbo.ReplaceIntegersWithArabicNumbers(topicFullCode)
It shows the following results from the SQL Server 2005 query window.
But when I show this data in Gridview the decimal point seems like comma (,) as shown in the following figure.
I need to know why this is happening and a solution of it.
Aucun commentaire:
Enregistrer un commentaire