I want to create a table in my function but I have trouble in adding nonunique index on OBJECT_ID.
DECLARE @VIEW_MY_DATA TABLE
(
[AREA_ID] INT,
[OBJECT_ID] INT,
[PARENT_ID] INT,
[OBJECT_TYPE] varchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS,
[RELATION] varchar(50)
)
I could not use CREATE TABLE in function. How to make it in SQL Server 2012?
CREATEa table, or declare a table variable in a function? This seems like you are therefore using a multi-line function, which are far slower than an inline function.@VIEW_MY_DATAisn't a temporary table, it's a table variable. They are completely different. But, again, switch to an inline function; they are far faster.