How can we help you today? How can we help you today?

INSERT INTO ... doesn't return the correct column order

Hi,

I have a table function with a table as return value.
For example:
CREATE FUNCTION [dbo].[GetAddress] (
)
RETURNS @Result TABLE (
    _ID INT
    , LastName NVARCHAR(MAX) 
    , FirstName NVARCHAR(MAX) 
    , ZIPCode NVARCHAR(100) 
)
AS
BEGIN

    INSERT INTO @Result
            (LastName
           , [_ID]
           , ZIPCode
           , FirstName)
    VALUES  ( -- LastName
     -- _ID
     -- ZIPCode
     -- FirstName
             )

END
GO

When I type the INSERT INTO the SQL-Prompt returns the columns in the wrong order!
:roll:

It works when the table is created with a DECLARE statement.
TSchwab
0

Add comment

Please sign in to leave a comment.