HereGo nutsCREATE TABLE #myTemp99 (n int IDENTITY(1,1), TABLE_NAME varchar(256), COLUMN_NAME varchar(256))GOINSERT INTO #myTemp99(TABLE_NAME, COLUMN_NAME) SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.Columns WHERE DATA_TYPE IN ('char','varchar', 'nchar','nvarchar') ORDER BY TABLE_NAME, COLUMN_NAMEGOSELECT * FROM #myTemp99GOSELECT SQL FROM (SELECT 'UPDATE ' + TABLE_NAME + CHAR(13) + CHAR(10) + ' SET ' + COLUMN_NAME + ' = REPLACE(' +COLUMN_NAME+','+''''+'"'+''''+','+''''+''''+')' AS SQL, TABLE_NAME, 1 AS SQLGroup, n FROM #myTemp99 o WHERE EXISTS (SELECT TABLE_NAME FROM #myTemp99 i WHERE i.TABLE_NAME = o.TABLE_NAME GROUP BY i.TABLE_NAME HAVING MIN(i.n) = o.n)UNION ALLSELECT ' , ' + COLUMN_NAME + ' = REPLACE(' +COLUMN_NAME+','+''''+'"'+''''+','+''''+''''+')' AS SQL, TABLE_NAME, 2 AS SQLGroup, n FROM #myTemp99 o WHERE EXISTS (SELECT TABLE_NAME FROM #myTemp99 i WHERE i.TABLE_NAME = o.TABLE_NAME GROUP BY i.TABLE_NAME HAVING MIN(i.n) <> o.n)UNION ALLSELECT 'GO' AS SQL, TABLE_NAME, 3 AS SQLGroup, 9999999 AS n FROM #myTemp99 o WHERE EXISTS (SELECT TABLE_NAME FROM #myTemp99 i WHERE i.TABLE_NAME = o.TABLE_NAME GROUP BY i.TABLE_NAME HAVING MIN(i.n) = o.n)) AS XXXORDER BY TABLE_NAME, SQLGroup, nDROP TABLE #myTemp99GO
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam