Last active
August 14, 2025 08:03
-
-
Save Hameds/a97a6242dc8ff5f66980c343693b0a94 to your computer and use it in GitHub Desktop.
Replace Arabic ي & ك in SQL Server Database with Persian characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use [DATABASE_NAME]; | |
| DECLARE @Table NVARCHAR(MAX) | |
| DECLARE @Col NVARCHAR(MAX) | |
| DECLARE Table_Cursor CURSOR | |
| FOR | |
| --پيدا کردن تمام فيلدهاي متني تمام جداول ديتابيس جاري | |
| SELECT a.name, --table | |
| b.name --col | |
| FROM sysobjects a, | |
| syscolumns b | |
| WHERE a.id = b.id | |
| AND a.xtype = 'u' --User table | |
| AND ( | |
| b.xtype = 99 --ntext | |
| OR b.xtype = 35 -- text | |
| OR b.xtype = 231 --nvarchar | |
| OR b.xtype = 167 --varchar | |
| OR b.xtype = 175 --char | |
| OR b.xtype = 239 --nchar | |
| ) | |
| OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @Table,@Col | |
| WHILE (@@FETCH_STATUS = 0) | |
| BEGIN | |
| EXEC ( | |
| 'update [' + @Table + '] set [' + @Col + | |
| ']= REPLACE(REPLACE(CAST([' + @Col + | |
| '] as nvarchar(max)) , NCHAR(1610), NCHAR(1740)),NCHAR(1603),NCHAR(1705)) ' | |
| ) | |
| FETCH NEXT FROM Table_Cursor INTO @Table,@Col | |
| END CLOSE Table_Cursor DEALLOCATE Table_Cursor |
Author
Hameds
commented
Apr 14, 2020
این مربوط به `SQL Server` است. روی دیتابیس دیگری تست نکردم
Thank you very much for your clean coding, but if you complete it for the types and "ی" & "ک" it's so better
Hi There
Please check out this
https://github.com/AIAML/T-Sql/blob/main/solve_problem_persian_alpha.sql
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment