Skip to content
Advertisement

Passing Variable to SQL insert statement

I know this code here selects columns from one table and inserts it into another table. However, I have a value that I want to insert into one of the columns, how do I pass in the value?

This selects from on table and inserts into another…

However, I want column1 to have a value that I set above the code e.g MY_NAME varchar(20)

set @MY_NAME = “Helen”

Then my insert statement to be something like this:

Any help would be appreciated.

Advertisement

Answer

To achieve that you should do something like this:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement