November 22, 2006 at 11:14 pm
Can we get the structure (column name & length) of records returned by SP ?
November 23, 2006 at 7:09 am
No directly from sql server (unless using DTS). Here's what I would do :
IF EXISTS (SELECT * FROM dbo.SysObjects WHERE Name = 'DemoFMTONLY' AND XType = 'P')
DROP PROCEDURE dbo.DemoFMTONLY
GO
CREATE PROCEDURE dbo.DemoFMTONLY
AS
SET NOCOUNT ON
SELECT Name, Id FROM dbo.SysObjects WHERE XType = 'U'
SET NOCOUNT OFF
GO
SET FMTONLY ON --returns only the structure of the data
Go
--call this using ADO.
EXEC dbo.DemoFMTONLY
--then loop through all fields and fetch the datatype and lenght in the properties collection (iirc)
GO
SET FMTONLY OFF
GO
DROP PROCEDURE dbo.DemoFMTONLY
November 27, 2006 at 3:17 pm
Try looking at table "syscolumns". It includes not just table columns but also stored procedure columns .
For example:
SELECT *
FROM syscolumns WITH (NOLOCK)
WHERE id = OBJECT_ID(N'storedProcName')
ORDER BY colid
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 27, 2006 at 4:12 pm
It contains list of parameters, not columns from returning recordset.
Database just cannot contain this information.
SP may return different results depending on the values of parameters, it may return more than 1 recordset.
List of columns for which one you would prefer to see?
_____________
Code for TallyGenerator
November 27, 2006 at 4:31 pm
Sorry, correct, I mis-read the original q.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 27, 2006 at 6:11 pm
My purpose is.. I want to create a table from the record returned by SP. The SP is containing dynamic SQL, so it execute different SQL depends on the parameter.
example:
exec SPExecSQL 'Select IDCustomer,dateConfirm,ItemCode,ItemQty'
inside the SP I have to make another process and then save the result to table..
November 28, 2006 at 7:29 am
So you're building some sort of reporting tool?
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply