Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,inside a stored procedure which is created in databaseA I would like to pull the data from databaseB and place it into a table variable as followscreate procedure uspGetData@Date date, @value bitasdeclate @tblData table(field1 varchar(50), field2 date)--insert into tblData exec DatabaseB.dbo.uspAnotherProcedure @Date=@Date, @value=@valueNote that the above sp does indeed execute the stored proc in databaseB BUT if I take out the commented line i.e. insert into, then it fails and the message is:A severe error occurred on the current command. The results, if any, should be discarded.Any thoughts please?Thanks
bandi
Master Smack Fu Yak Hacker
2242 Posts
Posted - 2013-02-19 : 03:58:25
That statement should be insert into @tblData
USE studyGOCREATE PROCEDURE uspAnotherProcedure ASSELECT employee_id, department_id, salary FROM employees WHERE department_id Is nullUSE DB2GOCREATE procedure uspGetDataAsBEGIN declare @tblData table( empid INT, deptid INT, sal DEC(8,2)) insert into @tblData exec study.dbo.uspAnotherProcedure SELECT * FROM @tblDataENDEXEC uspGetData