Hi,
I need to insert result set of SP into a temp table, however it is giving the following error.
'The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction'
Please find my effort regarding this.
DECLARE @tempTable TABLE(ID INT, [Description] NVARCHAR(50));
INSERT @tempTable EXEC sp_MyTable] 100
select * from @tempTable
Any help would be apprciated.

Sahil SainiRank #1,646 · 933 reputationPosted Jul 27, 2017, 4:46 AM EDT
BEGIN TRY Write sql queries here END TRY BEGIN CATCH Declare @error int, @message varchar(4000), @xstate int;Ajay Mavatkar63 reputationPosted Jul 27, 2017, 10:55 PM EDT
Sahil SainiRank #1,646 · 933 reputationPosted Jul 27, 2017, 11:35 PM EDT
CREATE FUNCTION FunctionName (@ID varchar(30)) RETURNS TABLE AS RETURN (SELECT t1.Field1, t2.Field2 FROM tableName t1 JOIN tablename2 t2 ON t1.title_id = t2.title_id WHERE t2.ID = @ID) This function will return Field1 and Field2 by passing @ID as parameter to function. Call this in SP like --> INSERT INTO #YOUR_TEMP_TABLE SELECT * FROM FunctionName (12)Manish KumarRank #1,622 · 956 reputationPosted Jul 28, 2017, 3:17 AM EDT