SQL Server Table definition from stored procedure result set(来自存储过程结果集的 SQL Server 表定义)
问题描述
有人知道从存储过程结果集创建表定义的方法吗?
Is anyone aware of a way to create a table definition from a stored procedure result set?
我有一个存储过程,它生成一个包含 30 多个列的结果集,我想将其放入一个表中,而无需手动创建所有表列.
I have a stored procedure which produces a result set with 30+ columns, I'd like to get this into a table without having to manually create all the table columns.
是否有内置程序可以转储列名和类型..?
Is there a built in procedure that will dump out the column names and types..?
谢谢.
推荐答案
你可以"做到,但我不知道我是否会推荐它:
You "can" do it but I don't know if I'd recommend it:
EXEC sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
SELECT
*
INTO
#table
FROM
OPENROWSET(
'SQLNCLI',
'SERVER=.;Trusted_Connection=yes',
'EXEC StoredProcedureName'
)
这篇关于来自存储过程结果集的 SQL Server 表定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:来自存储过程结果集的 SQL Server 表定义


基础教程推荐
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01