What is position in SQLServer?

3

I have a question. I received the layout of a table which consists of:

Nome do campo | Tamanho | Posição | Tipo

The Position contains:

De | Até

And one of the fields is:

Histórico ( no caso da Posição ): 35 | 104

What exactly is this position?

    
asked by anonymous 15.10.2015 / 17:12

2 answers

3

This is the column position. By the descriptions this is a fixed size file, so each column of data is always in the same line position. Then the first column is obviously in position 0 of the line. The second column is at position 0 plus the size of the first column. The third column is the previous position plus the size of the previous column. So with the name and where each column starts you can manipulate it in whatever way is most convenient for you.

If you are programming, you will certainly use substring a lot. But SQL Server has an importer that lets you tell where these positions are and it cuts each column and imports it correctly. As long as the data is in order, of course.

In the case of de and até it means the starting position on the line where the column starts and where it ends. Then 35 means that you will have to skip 34 starting characters of the line to start picking up a data that is from this column ( Histórico ) and will get all the characters up to position 104.

This OS response has a step-by-step guide showing how the importer works.

    
15.10.2015 / 17:27
2

Well, the question does not seem to be specifically about SQL Server. It seems to be about import and export layouts. I'll respond and then we'll see the appropriate tags to pose the question.

A layout is a well synthesized data file that has things like this:

GAJ07123456789060720301149915072000583922180003801    00000000003427759000000547    000001AA 06     
GAJ07256704671015072030114991507200058876543210380    00000000006759542000000547    000002AA 06     
GAJ07256704671015072030114991507200058392218000380    00000000006463264000000547    000003AA 06     
GAJ07256704671015072030111234507200058392218000380    00000000004181042000000547    000004AA 06     
GAJ07256712234315072030114991507200054567218000380    00000000005645190000000547    000005AA 06     
GAJ07256704671015072030114991507200058392278900380    00000000007419465000000547    000006AA 06   

That is to say, humanly it is not easy to read it, but it can be read with the help of a layout document , which is what you have at hand. Notice that all rows have the same length.

This header here helps you read the bottom lines:

Nome do campo | Tamanho | Posição | Tipo

Indicating for you the name of the field in question, how many characters it has, what position of the line it starts, and where it ends.

Taking as an example:

Histórico (Posição): 35 | 104

Considering a line like these that I put as an example, you will read the substring from position (column) 35 to position (column) 104 of each line.

Try to grab an exported file and open it in Notepad or any text editor that identifies the cursor line and column.

    
15.10.2015 / 17:30