Showing posts with label copying. Show all posts
Showing posts with label copying. Show all posts

Sunday, March 25, 2012

(newbie) copying rows between tables via notepad

Hi
newbie question I'm sure
I have 2 databases on 2 different machines, there is no
connection between the 2. What I need is a way of
extracting particular rows from particular tables and adding them
to another database. The only viable way of doing this is via
email for unimportant reasons.
Via query analyser I can do a select and get the results in
text then manually adjust these back into an insert statement.
There must be a better way but I'm too new to this to know how
Any ideas?

Thanks
Fhttp://vyaskn.tripod.com/code.htm#inserts

--
David Portas
SQL Server MVP
--|||You can use bcp.exe or DTS to export the data to file, then the same
mechanism to import them at the destination - see Books Online for the
details. Or if you want to use INSERTs, then check this out:

http://vyaskn.tripod.com/code.htm#inserts

Simon|||Simon Hayes wrote:
> You can use bcp.exe or DTS to export the data to file, then the same
> mechanism to import them at the destination - see Books Online for
the
> details. Or if you want to use INSERTs, then check this out:
> http://vyaskn.tripod.com/code.htm#inserts
> Simon

Thanks for the reply, this looked like it would have been ideal but
this is the output I get, it gets cut off (column names changed to
protect
the innocent :-))

INSERT INTO [XXXXXXXXXXXXXX]
([XXXXXXXXXXXXX],[XXXXXXXXXXXX],[XXXXXXXXXXXXXXX],[XXXXXXXXXXXXXXXXXXX],[XXXXXXXXXXXXXXXXX],[XXXXXXXXXXXXXX],[XXXXXXXXXXX],[XXXXXXXXXXXXXXXXX],[XXXXXXXXXXXXXXX],[XXXXXXXXXXXXXXXXXXX],[XXXXXXXXXXXXXXXXXX])VALUES('7CC60B79-1B27-4|||(foldface@.yahoo.co.uk) writes:
> Thanks for the reply, this looked like it would have been ideal but
> this is the output I get, it gets cut off (column names changed to
> protect

Sounds like you should go into to Tools->Options->Results and adjust
"Maximum characters per column".

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for the reply, yes, that was it, it was in the faq for that SP
as well but I assumed it was the SP that wasn't working because I
briefly saw this comment, huge is a relative thing!
Works fine now, very handy

NOTE:This procedure may not work with tables with too many columns.
Results can be unpredictable with huge text columns