Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to create an external content type from a stored procedure. I'm hitting one problem, when creating a Read List Operation, though:

The wizard is not able to find any return parameters (see image), when my stored procedure ends with EXEC:

CREATE PROCEDURE getData
AS
BEGIN
  DECLARE @sql NVARCHAR ( MAX);
  EXEC @sql;
END

Now, if I use a common select, SharePoint is able to recognize return parameters:

CREATE PROCEDURE getData
AS
BEGIN
  SELECT * FROM data_table;
END

I need to use EXEC, as I use a lot of metadata in my procedure. Is this a limitation of Sharepoint? Can I get a workaround?

Return parameter

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

As a workaround, you could save the results of the EXEC into a table, and return that:

CREATE PROCEDURE getData
AS
BEGIN
  DECLARE @sql NVARCHAR ( MAX);
  DECLARE @table TABLE (
    field1 INT, ...
  );

  INSERT INTO @table (field1, ... )
    EXEC @sql;

  SELECT * FROM @table;
END
share|improve this answer
    
Indeed, that's what I had to do. Thanks. –  John Assymptoth Oct 23 '12 at 23:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.