问题描述
有人知道从存储过程结果集创建表定义的方法吗?
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' )