July 25, 2006 at 10:12 am
Hi my Super Smart Peeps!
How would i create insert statements for all the data/values in a table?
July 25, 2006 at 10:29 am
Use star sign
select *
or
insert into sometable
select *
N 56°04'39.16"
E 12°55'05.25"
July 25, 2006 at 10:36 am
It may not be the best method, and probably isn't, but it has worked for me in the past - I'm sure there is a better way - this does exactly that for titleauthor in pubs - just run it and paste the output in a new window and remove the last union select statement.
SET NOCOUNT ON
SELECT 'INSERT INTO titleauthor(au_id,title_id,au_ord,royaltyper)'
PRINT 'SELECT'
SELECT '''' + au_id + ''',''' + title_id + ''',''' + cast(au_ord AS varchar(50)) + ''',''' + cast(royaltyper AS varchar(50)) + '''UNION SELECT ' FROM titleauthor
July 25, 2006 at 11:12 am
Google is your friend:
http://www.google.co.uk/search?hl=en&q=create+insert+statements
Returns a whole heap of good stuff on the first page, including:
http://www.databasejournal.com/scripts/article.php/1502051
http://vyaskn.tripod.com/code/generate_inserts.txt
http://www.codeproject.com/database/InsertGeneratorPack.asp
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
July 25, 2006 at 1:25 pm
Cool, thanks you guys totally rock!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply