如何绕过 openquery 默认列不为空

发布于 2024-07-20 09:55:29 字数 205 浏览 4 评论 0原文

我有一个像这样的 sql server pass-thru 查询:

*select * into myTable from openquery (yourComputer, 'select x,y,z, from yourTable')*

问题是 myTable 中的列默认为非空,我将稍后想要向该表添加行,其中某些列为空。

我能绕过这个吗?

I have a sql server pass-thru query like this:

*select * into myTable from openquery (yourComputer, 'select x,y,z, from yourTable')*

The problem is the columns in myTable are defaulting to not null and I will later want to add rows to this table with some columns null.

Can I get round this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飞烟轻若梦 2024-07-27 09:55:29

在插入数据之前创建myTable,然后执行插入。

create table myTable (
    x int null,
    y int null,
    z int null
)
go
insert into myTable (x, y, z)
select x, y, z
from openquery (yourComputer, 'select x,y,z, from yourTable')

Create myTable before inserting data, then perform insert.

create table myTable (
    x int null,
    y int null,
    z int null
)
go
insert into myTable (x, y, z)
select x, y, z
from openquery (yourComputer, 'select x,y,z, from yourTable')
简美 2024-07-27 09:55:29

您可以将结果插入到临时表中,然后更新该表以将所有空值设置为“”,然后将临时表中的值插入到实际表中

you could insert the results into a temp table and then update the table to set all null values to '', then insert the values in the temp table to the actual table

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文