![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
SQL blurp: if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmp_scratch]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tmp_scratch] create table dbo.tmp_scratch (fld1 char(4), fld2 char(4), fld3 char(500)) INSERT INTO dbo.tmp_scratch (fld1, fld2, fld3) SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\;','SELECT * FROM test.txt') make a schemi.ini file in the "DefaultDir" folder containing this: [TEST.TXT] Format=FixedLength CharacterSet=ANSI ColNameHeader=False Col1=client_code Text Width 4 Col2=client_sub_code Text Width 4 Col3=client_name Text Width 500 Hope this helps - warning the credentials to execute the OPENROWSET against the text file driver (i.e. a dynamic data source leaves risk) are a bit strict - likely need to SA privs or knowledge on how to enabled it for a SQLServer account. http://www.sqldts.com/ http://rickhathaway.blogspot.com/ |
![]() |
| Thread Tools | |
| Display Modes | |
| |