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 2008 Forums
 Transact-SQL (2008)
 select into

Author  Topic 

mikebird
Aged Yak Warrior

529 Posts

Posted - 2011-07-05 : 08:29:38
I want to break down data from a flat file into separate normalised tables, starting with a bare, empty table: Agency with just columns agencyID smallint unique not null identity(1,1), Name varchar(20)

I want to just retrieve a list of values from the existing table and select them into there

what syntax do I need. It's so simple. I don't want to use a new table. I want to keep the table config above, and just put text from the base table in there


Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'into'.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-07-05 : 08:49:21
select .. into ... from ...
This creates a new table - is that what you want?

Without knowing what you'veexecuted it's difficult to correct it.
maybe

insert Agency (Name)
select distinct Name
from SourceTable



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-07-05 : 13:48:09
for getting data from file you might have to use OPENROWSET or use linked server

see

http://blog.lekevin.com/computer/database/open-a-delimited-text-file-using-openrowset-and-opendatasource/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -