RRinTetons
IS-IT--Management
I use temp tables to accomplish this, but I'd like to know how to do it with table vars.
I can create a temp table and call an existing sp to put data into it. The sp returns a selection that populates the temp table. The syntax for that is like:
CREATE TABLE #MyTempTable
<table def>
INSERT #MyTempTable
SELECT dbo.MySP(var1, var2)
and all is well
But I wanted to do it as
DECLARE @MyTempTable TABLE
<table def>
then the same INSERT doesn't work.
How do I populate the TABLE var in this case? Is it some sort of an assignment statement?
-
Richard Ray
Jackson Hole Mountain Resort
I can create a temp table and call an existing sp to put data into it. The sp returns a selection that populates the temp table. The syntax for that is like:
CREATE TABLE #MyTempTable
<table def>
INSERT #MyTempTable
SELECT dbo.MySP(var1, var2)
and all is well
But I wanted to do it as
DECLARE @MyTempTable TABLE
<table def>
then the same INSERT doesn't work.
How do I populate the TABLE var in this case? Is it some sort of an assignment statement?
-
Richard Ray
Jackson Hole Mountain Resort