I have a lookup table with about 10 records, I know I can script the structure to a text file, but how can I script the data to insert into commands?
+2
A:
The quick and dirty way is to run a select into a string and tell sql enterprise manager to give you text (not grid) as the output
SELECT 'INSERT INTO TABLES (fields here) VALUES (' + field1 + ', '....
Russell Steen
2009-10-26 16:33:23
+5
A:
Ten records, and it's urgent?
Just type it out manually. Should be pretty easy to cut-n-paste.
Aric TenEyck
2009-10-26 16:33:26
+1
A:
Do something like this:
select "insert into my_targ_table(my_field_1, my_field_2, ..., my_field_n) values(" || x.my_field_1_col || ", " || x.my_field_2_col || ");"
from my_source_table x
Then just run the script you've generated.
cakeforcerberus
2009-10-26 16:34:33
I had the same idea, only 28 seconds later.
recursive
2009-10-26 16:35:47
+1
A:
Assuming SQL Server...
SQL Management Studio will generate an insert script. Right-click your database and select Tasks-Export data
Dave Swersky
2009-10-26 16:35:11