/ * - In all tables, numerical types from char, varchar to nchar, NVARCHAR stored procedures
- Zou Jian 2004.02 (Reference Please keep this information) - * / / * - Call example: EXEC P_SET - * / IF EXISTS (Select * from dbo.sysObjects where id = Object_ID (n '[dbo]. P_set] ') And ObjectProperty (ID, N'isprocedure') = 1) DROP Procedure [DBO]. [p_set] Go Create Procedure P_set As Declare Tb Cursor for Select SQL = 'ALTER TABLE [' D.NAME '] Alter Column [' a.name '] N ' B.Name ' (' Cast (a.length * 2 as varchar) ') 'from syscolumns a left join systemypes b on a.xtype = B.XUSERTYPE INNER Join Sysobjects D on A.Id = D.ID and D.XTYPE = 'u' and d.name <> DTPROPERTIES 'Where B.Name in (' char ',' varchar ') And not exists (SELECT 1 from sysobjects WHERE Xtype = 'pk' and name in (select Name from sysindexes where indid in (select Indid from sysindexkeys where id = a.id and color = a.colid))))) - Master key can not modify Order by D.Name, a.name declare @SQL varchar (1000) Open TB fetch next from tb @Sql while @@ fetch_status = 0 begin exec (@sql) fetch next from tb @SQL END Close Tb Deallocate TB GO