如何在数据库之间传递表值参数? [英] How do you you pass table valued parameters between databases?

查看:283
本文介绍了如何在数据库之间传递表值参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库(db1)中有一个存储过程;该存储过程接受表值参数.如何从另一个数据库(db2)调用存储过程,并将表值参数传递给该存储过程?

我所做的是:我在db1中将用户数据类型创建为表:这是表value参数接受的存储过程的类型.我在db2中创建了类似文件,以便可以将记录传递到db1.

当我从db2调用存储过程时,sql server返回错误"operandi类型冲突:typexx与typexxx不兼容

我尝试过的事情:

我尝试过,但是Sql返回了错误消息.

There’s a stored procedure in a database ( db1); the stored procedure accepts a table valued parameter. How do I call the stored procedure from another database(db2), passing table valued parameter to it?

What I did was: I created a user datatype as table in db1: that is the type that the stored procedure that the table value parameter accepts. I created similar in db2 so that I can pass records to db1.

When I called the stored procedure from db2, sql server returns error "operandi type clash: typexx is incompatible with typexxx

What I have tried:

I tried but Sql returned Error message.

推荐答案

您不能.用户定义的类型(包括表类型)不能在数据库之间共享.

您不能在db2中创建一个参数,该参数引用db1中的表类型.即使在两个数据库中都创建了相同的类型,也无法将一个数据库中的该类型的变量传递给期望从另一个数据库中获得该类型的参数.

您将需要以其他方式传递数据-例如,使用临时表.
You can''t. User-defined types, including table types, cannot be shared between databases.

You can''t create a parameter in db2 which references the table type from db1. And even if you create an identical type in both, you can''t pass a variable of the type from one database to a parameter which expects the type from the other database.

You''ll need to pass the data in some other way - for example, by using a temporary table.


这篇关于如何在数据库之间传递表值参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆