question

vanenkevort avatar image
vanenkevort asked

How do I load data to SQL DB from SQL script

I have some sql script that generates the data and I need to load it to a [dbo].[test] table. How can this be done?

script
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jon Crawford avatar image
Jon Crawford answered

We have no data here, how does your sql script "generate[] the data"?

You can create and populate tables various ways,

method, the first:

CREATE TABLE someTable (column1 datatype, column2 datatype...column datatype);

INSERT INTO someTable (column1, column2) VALUES ('someValue','someOtherValue');

method, the second:

SELECT *

INTO someTable

FROM someOtherTable;

method, the third:

CREATE TABLE someTable (column1 datatype, column2 datatype...column datatype);

INSERT INTO someTable (column1, column2)

SELECT 'someValue','someOtherValue' UNION ALL

SELECT 'someThirdValue','someFourthValue' ;

method, the penultimate:

use the Task Wizard to import the data from a file into a new or existing table

method, ultimate (not recommended):

with two fingers on your right temple, focus very hard on a point just beyond the data, then relax your eyes and slowly a table will materialize (spoiler: it's a schooner...)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.