What’s position on Sqlserver?

Asked

Viewed 157 times

5

I have a question. I received the layout of a table containing:

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 would that position be?

  • This does not seem to be SQL or something from SQL Server, this to be a fixed size file. Pass more information to be sure and be able to answer.

  • So bigown. I only received a txt with this information, which contains the field name, size, position and type ( numeric, alpha, etc ). This txt was exported from sql server.

  • And what do you need to do with it? What to know?

  • I need to know what this position means, as it was exported from an sql server base and will be imported to another sql server base that belongs to another system. But the layout of this other system contains this information that I’m unable to understand about the position.

  • If I’m not mistaken, I think it’s the position of the line, but I’m not sure if that’s right.

  • Is this a collect txt, billet or something? who like this are usually banks, e.g.: character 0 through 6 is the information about the agency, 7 through 14 on the account and so will.

  • It is actually from a table of entries of an accounting program. That position would not be the position within the database?

  • No, I believe it would be position of characters, each line of the file would be something like line 1 20938429836721638217478563875349577 line 233938429836721638217478563875349577. In theory all lines would have the same length.

Show 3 more comments

2 answers

4


It is the position of the column. By the descriptions this is a file of fixed size, so each column of data is always at the same position of the row. So the first column is obviously at position 0 of the row. 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 as it is most convenient for you.

If you are going to do programming you will certainly use a lot substring, but SQL Server has an importer that allows you to tell where these positions are and itself cuts each column and matters correctly, as long as the data is in order, of course.

In the case of de and até means the initial position on the line where the column starts and where it ends. So 35 means you have to skip 34 initial characters of the line to start taking a die that is from this column (Histórico) and will pick up all the characters until position 104.

That one response from the OS has a step by step showing the functioning of the importer.

  • 2

    I think it would be interesting to put a link that teaches the step-by-step import. It’ll save him having to write a program or something just to make the import.

2

Well, the question does not seem to be specifically about SQL Server. It seems to be about import and export layouts. I will answer and then we will see the tags appropriate 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   

I mean, humanly it’s not easy to read it, but it can be read with the help of a layout document, which is what you have at hand. Note that all lines have the same length.

This header here helps to read the bottom lines:

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

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

Taking as an example:

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

Considering a line like these I’ve put up for example, you’ll read the substring from position (column) 35 to position (column) 104 of each row.

Try taking an exported file and opening it in Notepad or any text editor that identifies the cursor row and column.

  • It’s probably an export of data from the database to some file that needs to be sent to some organ or bank. An appropriate tag would be EDI (Electronic Data Interchange) which is the standard market model for exchange of positional type information files.

  • @Marcosregis You can put your suggestion here, please?

  • I put it there. One important thing to include in the answer is that for the creation of this type of file it is necessary to use a lot the padding and the alignment according to the type of data. Textual data will always be left-aligned with blanks on the right while numerics will be right-aligned with zeros on the left, which is why in the layout the questioner placed the type information.

  • @Marcosregis So, this type of information we usually put on the Wiki tag. Since the tag doesn’t exist yet, I’m just waiting for some time for people to weigh in, and then we create the tag.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.