This error occurs when a variable name is preceded by # instead of @. # is used to declare temporary table
declare #myi int
Should be replaced by
declare @myi int
Its all about structured query language (SQL) - SQL Query Snippets, LINQ Snippets, SQL Stored Procedures, SQL Server Articles, SQL Server Feeds, SQL Server Analytics, SQL Server Integration Services (SSIS), Microsoft SQL Server BIG DATA - HortonWorks, SQL Server CRM Integration
CREATE FUNCTION ReturnATable() RETURNS @TabVar TABLE ( OrderID int not null, OrderDate datetime, OrderStatus bit, OrderValue decimal, BilledBy varchar(20) ) AS BEGIN DEclare @Date datetime ; Set @Date= GETDATE(); Insert Into @TabVar values (21, @Date , 1, 212.42, 'Jose'); return END
Select * from ReturnATable()