更改现有的列类型 [英] Alter existing column type
本文介绍了更改现有的列类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的后续脚本给我一个类似
的错误
消息4902,第16级,状态1,第14行
无法找到对象"@table",因为它不存在或您没有权限.
My follwing script give me an error like
Msg 4902, Level 16, State 1, Line 14
Cannot find the object "@table" because it does not exist or you do not have permissions.
DECLARE @table nchar (15),
@columnName nvarchar(30),
@columnSize int
DECLARE changes_cursor cursor for
SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_MAXIMUM_LENGTH AS Size FROM INFORMATION_SCHEMA.COLUMNS
where DATA_TYPE=''nchar'' and Table_Name=''tt''
order by TABLE_NAME
OPEN changes_cursor
FETCH changes_cursor INTO @table, @columnName,@columnSize
WHILE @@fetch_status = 0
BEGIN
ALTER TABLE "@table"
ALTER COLUMN "@columnName" varchar(10)
END
FETCH changes_cursor INTO @table, @columnName,@columnSize
CLOSE changes_cursor
DEALLOCATE changes_cursor
推荐答案
你好
尝试像这样的例子
hello
try like this example
declare @TableVar table (
NewPK int identity(1,1),
CustomerID nchar(5) NOT NULL )
Insert Into @TableVar (CustomerID)
Select CustomerID
From Customers
Select Top 5 *
from @TableVar
您已经声明了表,但未指定该表的列.
谢谢
sanjeev.
you have declared the table but not specify the column to that.
thanks
sanjeev.
这篇关于更改现有的列类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文