Home All Groups Group Topic Archive Search About

Inserting info in a table

Author
15 Apr 2006 3:13 AM
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

Author
15 Apr 2006 5:54 AM
Cor Ligthert [MVP]
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
Author
15 Apr 2006 6:54 AM
Cerebrus
>> 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 ! ;-)
Author
15 Apr 2006 9:23 AM
OHM ( One Handed Man )
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

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net

Show quote
"John" <John@nospam.infovis.co.uk> wrote in message
news:OZS1TqDYGHA.4992@TK2MSFTNGP03.phx.gbl...
> 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
>
Author
17 Apr 2006 1:18 PM
Russell
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.
Author
17 Apr 2006 1:27 PM
OHM ( One Handed Man )
Absolutely, good point !

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net


Show quote
"Russell" <russ***@goisc.com> wrote in message
news:1145279913.465733.301470@u72g2000cwu.googlegroups.com...
> 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.
>

AddThis Social Bookmark Button