denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.81k stars 493 forks source link

Can Tabled-Value-Parameters feature support dynamic struct? #757

Open zhanghaiyang9999 opened 2 years ago

zhanghaiyang9999 commented 2 years ago

For example, there are two tables in MSSQL, one is table1,another is table2, but table1 and table2 have different fields. see table1 has 3 fields such as ID, Name, Age, and table2 has 4 fields such as ID, Company, Position, Salary, can we dynamically create different struct to use the TVP feature? if we pre-define the struct in code for the two tables, it's ok, but if we have hundreds of tables, it's impossible to pre-define the struct for every table.

Thanks!

NikitaDef commented 2 years ago

For example, there are two tables in MSSQL, one is table1,another is table2, but table1 and table2 have different fields. see table1 has 3 fields such as ID, Name, Age, and table2 has 4 fields such as ID, Company, Position, Salary, can we dynamically create different struct to use the TVP feature? if we pre-define the struct in code for the two tables, it's ok, but if we have hundreds of tables, it's impossible to pre-define the struct for every table.

Thanks!

Hi, can you write some example of code. I don't understand how to want use TVP