declare @table varchar(20) declare @field varchar(20) declare @sql nvarchar(200)declare cursor getvarchar forselect a.name,b.name from sysobjects a,syscolumns b,systypes c where a.xtype='U' and a.id=b.id and b.xtype=c.xtype and c.name='nvarchar'open getvarchar fetch next from getvarchar into @table,@fieldwhile @@fetch_status<>-1 begin set @sql='alter table '+@table+' alter column '+@field+' nvarchar' exec(@sql) fetch next from getvarchar into @table,@field,@type end
谢谢!
忘了写上了,的确用nvarchar试过.
可以,但是有big5码存储过程仍然不行:(
或者给点提示, 比如说可能需要参考到某个系统表之类?谢谢!
declare @field varchar(20)
declare @sql nvarchar(200)declare cursor getvarchar forselect a.name,b.name from sysobjects a,syscolumns b,systypes c where a.xtype='U' and a.id=b.id and b.xtype=c.xtype and c.name='nvarchar'open getvarchar
fetch next from getvarchar into @table,@fieldwhile @@fetch_status<>-1
begin
set @sql='alter table '+@table+' alter column '+@field+' nvarchar'
exec(@sql)
fetch next from getvarchar into @table,@field,@type
end
物件 'PK_ContainerItem' 與 資料行 'VoucherNo' 具相依性。
伺服器: 訊息 4922,層級 16,狀態 1,行 1
ALTER TABLE ALTER COLUMN VoucherNo 已經失敗,因為有一個或多個物件存取這個資料行。
你改了繁体系统的sqlserver的charset后,使用sqlserver的工具是能正常,但是其他客户端程序还是插入的繁体字符,数据库看到的当然是乱码。
改成nvarchar可能是最好的办法,本来这个字段就是为了解决国际化的软件的问题。
不过用了nvarchar后,再繁体系统录入的数据,在简体系统看到的同样是繁体字符(简体系统要支持unicode字符)
select OBJECTPROPERTY(OBJECT_ID(tbName) , 'TableHasPrimaryKey')
键是什么?
select COLUMN_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME = tbName