I have this table in procedure
DECLARE @tbl_copy TABLE
(
BasicObsEntered NVARCHAR(20),
BasicObsEnteredDate NVARCHAR(100),
[STATUS] nvarchar(10),
CategoryOne nvarchar(30),
NAME nvarchar(125),
ItemName nvarchar(125),
[Value] nvarchar(60),
UnitOfMeasure nvarchar(15),
AbnormalityCode nvarchar(10),
ReferenceUpperLimit nvarchar(10),
ReferenceLowerLimit nvarchar(10),
ResultGUID NVARCHAR(32)
)
I inserted data in this table successfully and wrote following update Query
Update @tbl_copy SET BasicobsEntered = b.BasicobsEntered , BasicObsEnteredDate =b.BasicObsEnteredDate from @tbl_copy INNER JOIN @tbl_cpy1 b on @tbl_copy.Name = @tbl_cpy1.Name and @tbl_copy.ItemName = @tbl_cpy1.ItemName and b.[Status]='F' and @tbl_copy.Status='P'
This works fine when i am using #tbl_Copy table..means to say memory table.
Error comes when using table variable as
Msg 137, Level 16, State 1, Procedure ResultList_Optimization, Line 172<br />
Must declare the scalar variable "@tbl_copy".