来自存储过程结果集的 SQL Server 表定义 [英] SQL Server Table definition from stored procedure result set

查看:36
本文介绍了来自存储过程结果集的 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 表定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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