Created
November 5, 2013 07:39
-
-
Save mahdi/7315281 to your computer and use it in GitHub Desktop.
This file contains 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 DB; | |
DECLARE @Table NVARCHAR(MAX), | |
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment