Inserting info in a table

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I have a set of values that I need to insert and sql server table. My
question is, out of all the methods what is the best (in terms of being
simplest/most straightforward) method to do that?

Thanks

Regards
 
John,
I have a set of values that I need to insert and sql server table. My
question is, out of all the methods what is the best (in terms of being
simplest/most straightforward) method to do that?
Assuming you want to do this with a .Net program.

Create a Transact SQL insert string and process that with execute.nonquery

I hope this helps,

Cor
 
what is the best (in terms of being simplest/most straightforward) method

Depends on what you find the simplest. Maybe you could enter the data
in manually ! What could be simpler ! ;-)
 
The most basic syntax is


INSERT INTO tableName VALUES( value1, value2 . . . . . )

Things to bear in mind about using this approach.

1.) Your values MUST be in sequence with the table design
2.) If ANY of your values include single quotes ' then your statement will
fail.

Using Parameters if more time consuming, but far less prone to error
 
Parameters will also prevent any possible "Sql Injection"attack, as
something that would be an executable statement if inlined is simply
text if it's a parameter value.
 
Back
Top