如何确定一条SQL结果的数据类型? [英] How to determine the datatypes of the results of a SQL?

查看:34
本文介绍了如何确定一条SQL结果的数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 SQL 查询,它从数据库的许多表/视图中提取大量字段.我们需要将规范放在一起以与第三方集成,编译结果集的数据类型最快的方法是什么?

We have a SQL query that pulls a large number of fields from many tables/views from a database. We need to put a spec together for integration with a 3rd party, what is the quickest way to compile the data types of the result set?

说明:

  • 涉及 25 个以上的表/视图,因此表级别的功能仍然很繁琐.
  • 所有工作目前都在 Microsoft SQL Server Management Studio 中完成.

推荐答案

您可以使用 SET FMTONLY ON 运行查询,但这可能无法帮助您轻松确定返回的数据类型,因为您只在管理工作室工作.如果是我,我想我会临时创建一个与存储过程具有相同主体的视图(您可能必须为任何参数声明变量).然后,您可以使用已经讨论过的 INFORMATION_SCHEMA 查询查看视图返回的列.

You can run the query with SET FMTONLY ON, but that might not help you to easily determine the data types returned, since you're working in management studio only. If it was me, I think I'd create a view temporarily with the same body as the stored procedure (you may have to declare variables for any parameters). You can then look at the columns returned by the view with the INFORMATION_SCHEMA queries already discussed.

这篇关于如何确定一条SQL结果的数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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