D
D
Dmitry Gavrilenko2017-05-26 14:04:27
Programming
Dmitry Gavrilenko, 2017-05-26 14:04:27

Table variable column order in procedure?

There is a cron that returns tabular data. We wrap this data in the program and pass to the input of another chronicle that accepts a table variable. Everything is very good, but if the order of the columns of the input data does not match the order of the columns in the receiving data cron, then the data will be written as is. I'm talking about the fact that in the program, we name the columns as they came. According to the idea, sql was supposed to scatter the data not in order, but in columns, but it does not.
Stores operate on data corresponding to the same type (table), which we also indicate when transferring.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tomatho, 2017-05-26
@tomatho

In INSERT , specify the order of values ​​through the appropriate syntax:

INSERT INTO Production.UnitMeasure (Name, UnitMeasureCode,  
    ModifiedDate)  
VALUES (N'Square Yards', N'Y2', GETDATE());

This is an example from MSDN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question