I've got the following temp table and code that populates the temp table just fine:
The SP beign called in the Insert statement returns the 4 fields to populate the temp table....all is fine. But I've implemented some other code in there that gives me an additional field that I want to add to the temp table. Problem is, the additional field is in a variable, not coming from the SP. So my ? is, can I somehow add this to the Insert statement without it bombing? I've tried several variation of it but can't seem to get it to work. Here's what I've tried:
The above code compiles ok, but when ran it says:
any ideas?
Code:
CREATE TABLE #DistinctProductVersions
(
VersionNumber varchar(50),
ProductVersionID int,
OrderBy int,
TotalCount int
)
INSERT INTO #DistinctProductVersions
EXEC dbo.ASC_NGSC_GetAllSiteVersionNumbers
The SP beign called in the Insert statement returns the 4 fields to populate the temp table....all is fine. But I've implemented some other code in there that gives me an additional field that I want to add to the temp table. Problem is, the additional field is in a variable, not coming from the SP. So my ? is, can I somehow add this to the Insert statement without it bombing? I've tried several variation of it but can't seem to get it to work. Here's what I've tried:
Code:
CREATE TABLE #DistinctProductVersions
(
VersionNumber varchar(50),
ProductVersionID int,
OrderBy int,
TotalCount int,
DBName varchar(50)
)
--Added the extra field DBName to the temp table.
INSERT INTO #DistinctProductVersions(VersionNumber, ProductVersionID, OrderBy, TotalCount, DBName)
EXEC dbo.ASC_NGSC_GetAllSiteVersionNumbers @DBName SELECT @DBName
The above code compiles ok, but when ran it says:
Code:
(14 row(s) affected)
Server: Msg 213, Level 16, State 7, Line 2
Insert Error: Column name or number of supplied values does not match table definition.
any ideas?