• mar.ko (8/18/2015)


    Guys - is there a better way to do this ?

    INSERT INTO @TESTTAB SELECT * FROM dbo.UTIL_TABLE_FROM_STRING(@szDelimit)

    Note....The stored function returns a table.

    Why doesn't this work ?:

    SET @TESTTAB = (SELECT * FROM dbo.UTIL_TABLE_FROM_STRING(@szDelimit))

    I wonder if I need to establish a user-defined tabletype ? Will that do it ?

    I really just want a pointer to the table, and not to have to create a new copy.

    Better way? Depends on what you mean by better. UDTTs are stored in tempdb and can have primary key and unique constraints and thus are indexed.

    Why doesn't the SET statement work? Because the "pointer assignment" you're trying to do only works when passing a UDTT as a parameter. And even then it comes in as a readonly table (readonly pointer).

    Personally I love UDTTs for the elegant object-like code they enable one to write.