Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How can I specify Import field constraints?

Author  Topic 

parrot
Posting Yak Master

132 Posts

Posted - 2012-12-30 : 13:05:45
I am trying to import a delimited flat file data source into a table that I have created with the desired attributes using SQL Server Management Studio. I started by exporting the table as a flat file. Then I created the table definitions on the new database. Then I imported the flatfile source into my new table but it gives me an error that the table is already defined. If I don't define the table ahead of time, the flat file will just create a varchar(50) attribute for every field item. So how can I import a table from a delimited flat file into a table with an existing definition so I can retain the proper field definitions?
Dave

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-12-30 : 16:53:22
Are you importing it somehow as SELECT * INTO AlreadyCreatedTable instead of
INSERT INTO AlreadyCreatedTable
SELECT *
FROM

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

parrot
Posting Yak Master

132 Posts

Posted - 2012-12-30 : 17:48:32
I am importing under the tasks menu item as a flat file which only has comma delimited data. I am not running any script. I know that in MYSQL you can use a LOAD DATA INFILE command but there is no such command that I know of in Microsoft SQL. I tried to use a LOAD DATA INFILE command in a script and got an error. Is there an SQL script command that allows me to upload data from an input file?
Go to Top of Page
   

- Advertisement -