sql改变列的类型
表a有一个列remarks类型nvarchar(10),可不可以写一段sql代码判断这个表要有remarks且类型为nvarchar(10)的话,将其改为nvarchar(100).
是不是要用到系统表?请高手帮帮忙
[解决办法]
Create Table A
(remarksnvarchar(10))
GO
If Exists(Select A.Name From Syscolumns A Left Join Systypes B On A.Xtype=B.xusertype Inner Join Sysobjects C On A.ID = C.ID And C.Xtype= 'U ' Where C.Name = 'A ' And A.Name = 'remarks ' And B.Name = 'nvarchar ' And COLUMNPROPERTY(A.ID,A.Name, 'PRECISION ') = 10)
Alter Table A Alter Column remarks nvarchar(100)
GO