There was a need to insert into a certain table, information about the table I take from here INFORMATION_SCHEMA. First, I recognize field names, data types.
Question: How to generate the corresponding INSERT request?
Procedure.

  • It seems to me that generating a query is outside the SQL language. Additional resources, add-ins (PL) and other programming languages ​​are needed. - BuilderC

1 answer 1

I decided myself. Created a @inert type @inert variable. Filled it with @insert = 'INSERT INTO table VALUES ("qwerty", "qwerty2")' and executed EXEC(@insert) . Everything turned out to be much easier than I thought. )

  • 2
    Keep in mind that for such a trick, you need the rights of inserting into the table for the caller of the procedure. They are not always. - maxleo
  • Everything is taken into account, I just completely forgot about exec (). - namak7