Hi all,
i need to update Database column based on the ColumnList.txt file
Condition:
if there is a new column added in the columnList.txt
Then the database Column must update as well.
Example : Day 1
ColumnList.txt has a 5 column
and same column in the database.
Day 2
ColumnList.txt has a 8 column
then the database must update based on the columns from columnList.txt
this is a continuation of my previous topic
any help would be highly appreciated
@Vincent_Nuestro -
Sequence:
1. Read Text File:
File Path: "ColumnList.txt"
Output: columnsFromFile (List<String>)
2. Connect:
Database Provider: Select appropriate database provider
Connection String: Your database connection string
3. Execute Query:
SQL: "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'YourTableName'"
Output: existingColumns (DataTable)
4. For Each:
TypeArgument: String
Values: columnsFromFile
Body:
If:
Condition: Not existingColumns.AsEnumerable().Any(Function(row) row("COLUMN_NAME").ToString = item)
Then:
Assign:
alterSql = "ALTER TABLE YourTableName ADD " & item & " VARCHAR(255)"
Execute Non Query:
SQL: alterSql
5. Close Connection
1 Like