RE: Creating an Index for Temporary table returned by Functions
From: dance2die (dance2die_at_discussions.microsoft.com)
Date: 11/09/04
- Next message: Damon Allison: "Re: sp_xml_preparedocument"
- Previous message: Louis Davidson: "Re: how to conver nvarchar with value like(12.23) to time (12:23)"
- In reply to: dance2die: "Creating an Index for Temporary table returned by Functions"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 9 Nov 2004 13:03:03 -0800
Thanks for the help guys.
I have decided to go with a temporary table instead of using an UDF.
I have tried, both Temp tables and Dynamic SQL.
While Temp table solution seemed to be working, Dynamic SQL didn't in my case.
But it seems like I have learned a lesson that a table isn't necessarily
should be called a table without a primary key.
"dance2die" wrote:
> I have a function returning a table.
> ==========
> CREATE FUNCTION fnExample()
> RETURNS @exTable TABLE (
> f1 char(8)
> , f2 datetime
> , f3 integer
> )
> AS
> BEGIN
> -- MAIN
> -- Fill @exTable...
> RETURN
> END
> ==========
>
> Rows returned from the @exTable is not UNIQUE. therefore I cannot use UNIQUE
> or PRIMARY KEY constraints to implicitly creating indexes on any of fields.
>
> When I tried
> ==========
> CREATE INDEX ix_exTable ON @exTable(f1 ASC, f2, ASC, f3 ASC)
> -- with GO and without GO
> ==========
> in that "--MAIN" section, I received an error(i had to translate the error
> from Korean to English)
>
> "There is an Error near @exTable".
>
> Basically I kept on getting errors on creating indexes before filling up
> @exTable.
> I'd appreciate your kind help.
- Next message: Damon Allison: "Re: sp_xml_preparedocument"
- Previous message: Louis Davidson: "Re: how to conver nvarchar with value like(12.23) to time (12:23)"
- In reply to: dance2die: "Creating an Index for Temporary table returned by Functions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|