是否可以更改视图中列的数据类型? [英] Is it possible to change the datatype of a column in a view?
本文介绍了是否可以更改视图中列的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通常我运行这样的脚本:
ALTER TABLE [TABLE]
ALTER COLUMN [Column] NVARCHAR (40);
结果是表中的字段转换为nvarchar。但是对于一个视图做同样的事情的语法是什么?
pre$ b
解决方案
CREATE VIEW AView
AS
SELECT CAST(title AS char(50))
FROM titles
因此,在msdn页面上查看CAST和CONVERT,了解完整信息
Usually I run a script like this:
ALTER TABLE [TABLE]
ALTER COLUMN [Column] NVARCHAR(40);
The result is that the field in the table gets converted to nvarchar. But what is the syntax for doing the same thing for a view? Or is that even possible?
解决方案
Sure
CREATE VIEW AView
AS
SELECT CAST(title AS char(50))
FROM titles
So check out CAST and also CONVERT on the msdn pages for full info
这篇关于是否可以更改视图中列的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文