Home All Groups Group Topic Archive Search About

How to get table data ?

Author
6 Sep 2006 12:25 PM
Jarod
Hi!
I'd like a tool that will generate Insert statements for my whole table with
data. What tool is best for this job ?
Jarod

Author
6 Sep 2006 12:41 PM
Tracy McKibben
Jarod wrote:
> Hi!
> I'd like a tool that will generate Insert statements for my whole table
> with data. What tool is best for this job ?
> Jarod

I just put up a rough script that I use for this...
http://realsqlguy.com/serendipity/archives/15-Table-For-Two.html



--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
6 Sep 2006 1:03 PM
Jarod
>> Hi!
>> I'd like a tool that will generate Insert statements for my whole table
>> with data. What tool is best for this job ?
>> Jarod
>
> I just put up a rough script that I use for this...
> http://realsqlguy.com/serendipity/archives/15-Table-For-Two.html
>

But what I really need is a script or program that will generate data from
table as INSERT statements so:
INSERT INTO EMPLOYEES VALUES(1, 'John', NULL, 10, 10)

and so on.
So if I have Employees table I'll get a whole list of INSERT INTO ...
Jarod
Author
6 Sep 2006 1:31 PM
Tracy McKibben
Jarod wrote:
Show quote
>>> Hi!
>>> I'd like a tool that will generate Insert statements for my whole
>>> table with data. What tool is best for this job ?
>>> Jarod
>>
>> I just put up a rough script that I use for this...
>> http://realsqlguy.com/serendipity/archives/15-Table-For-Two.html
>>
>
> But what I really need is a script or program that will generate data
> from table as INSERT statements so:
> INSERT INTO EMPLOYEES VALUES(1, 'John', NULL, 10, 10)
>
> and so on.
> So if I have Employees table I'll get a whole list of INSERT INTO ...
> Jarod

Ummm, did you look at the script?  That's exactly what it does...


--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
6 Sep 2006 1:49 PM
Jim Underwood
I think what the OP is asking for is a text file containing the input
statements, whereas your script actually executes the statements.

The following change, I think, will do it.

change
EXECUTE (@SQLCmd)
to
execute sp_executesql
          N'Select @Insert,'
          N'@Insert nvarchar(4000)',
          @Insert= @SQLCmd


Show quote
"Tracy McKibben" <tr***@realsqlguy.com> wrote in message
news:44FECDAB.4000909@realsqlguy.com...
> Jarod wrote:
> >>> Hi!
> >>> I'd like a tool that will generate Insert statements for my whole
> >>> table with data. What tool is best for this job ?
> >>> Jarod
> >>
> >> I just put up a rough script that I use for this...
> >> http://realsqlguy.com/serendipity/archives/15-Table-For-Two.html
> >>
> >
> > But what I really need is a script or program that will generate data
> > from table as INSERT statements so:
> > INSERT INTO EMPLOYEES VALUES(1, 'John', NULL, 10, 10)
> >
> > and so on.
> > So if I have Employees table I'll get a whole list of INSERT INTO ...
> > Jarod
>
> Ummm, did you look at the script?  That's exactly what it does...
>
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
Author
6 Sep 2006 1:55 PM
Tracy McKibben
Jim Underwood wrote:
> I think what the OP is asking for is a text file containing the input
> statements, whereas your script actually executes the statements.
>
> The following change, I think, will do it.
>
> change
> EXECUTE (@SQLCmd)
> to
> execute sp_executesql
>           N'Select @Insert,'
>           N'@Insert nvarchar(4000)',
>           @Insert= @SQLCmd
>

Nope.  My script builds a temporary stored proc, executes that proc,
producing a list of INSERT statements that can be saved to a file,
copy/pasted, whatever.  The EXECUTE statement that you're referring to
executes a dynamic SELECT statement that produces each INSERT statement
returned by the proc.


--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
6 Sep 2006 1:57 PM
Jim Underwood
GAH! never mind...
I shoudl never post before my first cup of coffee.

That is exactly what the script is doing.

Show quote
"Jim Underwood" <james.underwoodATfallonclinic.com> wrote in message
news:ecP18sb0GHA.1256@TK2MSFTNGP02.phx.gbl...
> I think what the OP is asking for is a text file containing the input
> statements, whereas your script actually executes the statements.
>
> The following change, I think, will do it.
>
> change
> EXECUTE (@SQLCmd)
> to
> execute sp_executesql
>           N'Select @Insert,'
>           N'@Insert nvarchar(4000)',
>           @Insert= @SQLCmd
>
>
> "Tracy McKibben" <tr***@realsqlguy.com> wrote in message
> news:44FECDAB.4000909@realsqlguy.com...
> > Jarod wrote:
> > >>> Hi!
> > >>> I'd like a tool that will generate Insert statements for my whole
> > >>> table with data. What tool is best for this job ?
> > >>> Jarod
> > >>
> > >> I just put up a rough script that I use for this...
> > >> http://realsqlguy.com/serendipity/archives/15-Table-For-Two.html
> > >>
> > >
> > > But what I really need is a script or program that will generate data
> > > from table as INSERT statements so:
> > > INSERT INTO EMPLOYEES VALUES(1, 'John', NULL, 10, 10)
> > >
> > > and so on.
> > > So if I have Employees table I'll get a whole list of INSERT INTO ...
> > > Jarod
> >
> > Ummm, did you look at the script?  That's exactly what it does...
> >
> >
> > --
> > Tracy McKibben
> > MCDBA
> > http://www.realsqlguy.com
>
>
Author
6 Sep 2006 2:08 PM
Tracy McKibben
Jim Underwood wrote:
> GAH! never mind...
> I shoudl never post before my first cup of coffee.
>
> That is exactly what the script is doing.
>

Yep!  :-)

The script needs some cleanup, commenting, etc., but I just threw it up
quickly when I saw the original question this morning.


--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
6 Sep 2006 1:02 PM
Hari Prasad
Hi,

This is wonderful script from Vyas.

http://vyaskn.tripod.com/code/generate_inserts.txt

Thanks
Hari
SQL Server MVP

Show quote
"Jarod" <blueice@NOSPAM.gazeta.pl> wrote in message
news:u2QL89a0GHA.4772@TK2MSFTNGP03.phx.gbl...
> Hi!
> I'd like a tool that will generate Insert statements for my whole table
> with data. What tool is best for this job ?
> Jarod
Author
7 Sep 2006 9:49 AM
Steve Dassin
Qualite is a free utility that will generate insert statements
and has many other features.

http://www.rac4sql.net/qalite_main.asp

best,
steve
http://racster.blogspot.com

AddThis Social Bookmark Button