Clear a particular column of data table in vb - vb.net

I have a data table which has 3 columns . I am populating the values of each column separately in a loop which causes the table structure to be in the format as shown in the image. How to clear every column at the beginning of the loop so that all data comes in a proper tabular format. In short I want to have a data table with variable number of rows possible for each column.

To clear every column at beginning of the loop you have two options:
loop all rows
remove column, add column
Depending on the plenty of rows the two options have different performances.
For large amount of rows i prefer the second option.

Related

Removing rows with duplicated column values based on another column's value

Hey guys, maybe this is a basic SQL qn. Say I have this very simple table, I need to run a simple sql statement to return a result like this:
Basically, the its to dedup Name based on it's row's Value column, whichever is larger should stay.
Thanks!
Framing the problem correctly would help you figure it out.
"Deduplication" suggests altering the table - starting with a state with duplicates, ending with a state without them. Usually done in three steps (getting the rows without duplicates into temp table, removing original table, renaming temp table).
"Removing rows with duplicated column values" also suggests alteration of data and derails train of thought.
What you do want is to get the entire table, and in cases where the columns you care about have multiple values attached get the highest one. One could say... group by columns you care about? And attach them to the highest value, a maximum value?
select id,name,max(value) from table group by id,name

How to identify a repeat column in postgreSQL, where the column has random input

I have two columns. ID, and Transcript. The numbers in the ID column are randomly generated. The Transcripts in Transcript are from an array that I cross-joined and unnested, which has generated several repeats of "ID" in Column 1 whenever there's multiple transcripts per ID.
I can't use the usual stack overflow "if" statements. The numbers in the ID column are randomly generated (and there's thousands of them), so I can't just write "if column ID is 'apple', then-."
I have to automatically identify when & where the column has a repeat, and then be able to take the second (and third, if there is one) rows, isolate the unique data in those rows, then append them onto the first row, in a new column. (I'm aware this would generate "null" data in other data rows' columns that don't have the new data. I presume I'd have to create new columns, pre-filled with '-' in them?)
I'm new to SQL, but does 'count' just tell the user the number of repeats for a particular input that the user specified?
Is there any way to write that number into a new column along a specific row (e.g., 'original instance of this ID') so that I can then issue a command based on that number? Otherwise, is it just telling the user how often something has repeated and isn't machine-readable to be used in additional steps?
Otherwise, can I number the duplicated IDs, then I can issue an order. 'if 1, insert into new column 1 row above if filled with '-. Else, insert transcript on the row above in new column 1 if column 1 has data '-'. Else if, put in column 2. etc.,'
I'm entirely lost as to how to even get it to recognise the duplication is occurring in a meaningful way, given the random nature of the ID system.

SQL select cell contents as column for dynamic range

I have a BEFORE table as the initial format and an AFTER table as the ideal format:
Select "Printer:" cells to column with corresponding data
Is it possible to select the corresponding 'Printer:%' above each small table into a left column by some sort of lookup/filter/dynamic rule where the numbered contents will vary in length as we receive this monthly report? I believe the relative ending line of each table will say "Not assigned" which may be able to be used as a stop. Thank you for considering.

How to append new columns with data from one table to another

I know the title might seem confusing but the real situation is as follow: I have two tables with existing data and both of them have n rows but different columns. The order of the rows in two tables do match. So the goal is such that after appending, the first row of the second table is appended to the first row of the first table, etc. and all the columns from the second table are added to the first table - basically just like paste two tables together.

how to find index of a row in sql server?

How can i fetch column names from a table on index basis, like I want to make a tables whose column name should be the name of last column fields of a result set of a query, but those result sets last columns value may be different at different execution time, so i want to know how can i fetch those index value of that last column to make a temp table with column name of those last columns value of a result set.
Is there any way/function in sql server to dynamically form that?
sp_helpindex:
Reports information about the indexes
on a table or view.
You can also use ROW_NUMBER as explained here