[英]How do I add a NULL column when SELECT'ing INTO a new table?
I have a statement like this: 我有这样的声明:
SELECT field1, field2, MyField = NULL
INTO NewTable
FROM OldTable
This does what I want with one exception: the field I created MyField
and filled with NULL
is an INT
type and I'd like it to be a VARCHAR
type. 这样做我想要的只有一个例外:我创建MyField
并填充NULL
的字段是INT
类型,我希望它是VARCHAR
类型。 I don't know how to modify the same statement to create the new field with the VARCHAR
type. 我不知道如何修改相同的语句来创建VARCHAR
类型的新字段。
Thanks. 谢谢。
尝试用。替换null
CAST(null as VARCHAR)
SELECT field1, field2, convert(varchar, NULL) as MyField
INTO NewTable
FROM OldTable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.