I'm trying to replace my temp tables with table data types, but I'm getting "must delcare" errors for my tables. It doesn't happen all the time. Is there any reason why I can't use more than one table data type in a sp? Here's an example of code from a sp that gives me such an error: create table #periodmsg ( Message_Code numeric(10, 0) ) declare @tempmsg table ( Message_Code numeric(10, 0) ) insert into #periodmsg(Message_Code) select TblMessage.Message_Code fromTblMessage inner join TblMessageCondition on (TblMessage.Message_Code = TblMessageCondition.Condition_MessageCode) whereTblMessageCondition.Condition_TableNum = 5 and TblMessageCondition.Condition_DateValue = @period insert into @tempmsg(Message_Code) select #periodmsg.Message_Code from#periodmsg inner join TblMessageCondition on (#periodmsg.Message_Code = TblMessageCondition.Condition_MessageCode) whereTblMessageCondition.Condition_TableNum = 1 and TblMessageCondition.Condition_NumValue = @usercode select count(@tempmsg.Message_Code), TblMessage.Message_Title, TblMessage.Message_Text fromTblMessage inner join @tempmsg on (TblMessage.Message_Code = @tempmsg.Message_Code) group by TblMessage.Message_Title, TblMessage.Message_Text I'm getting "Must declare the variable '@tempmsg'" on the last select. Any ideas?