Need a bit of help here, I'm moderately new to Sql Server running Sql Server 2000 and am trying to import a long text file into several tables. Each record in the text file is 3000 characters and the fields are of varying length and not delimited. I've searched through the forum and found an old thread ( that is pretty helpful, but I'm still doing something wrong. I'm trying to follow the advice EdwinGene (still out there?)suggested about using inserts and selects, but when I try to run the stored procedure(code below) I only get one record inserted, although it's parsed correctly. I'm sure that's because there's no looping, but isn't that the Cursor the previous thread warned against using?
Anyhow I'd appreciate any help.
Code
CREATE PROCEDURE dbo.usp_INS_TAKSData
AS
Declare
@AdminDate Char(4),
@Grade char(2),
@ESCRegion char(2),
@Campus char(3),
@LastName char(15),
@FirstName char(10),
@MI char(1),
@StudentSS char(9),
@Sex char(1),
@DOB char(8),
@StudentID char(6)
select @AdminDate=substring(col001,1,4),
@Grade=Substring(col001,5,2),
@ESCRegion=substring(col001,7,2),
@Campus=substring(col001,123,3),
@LastName=substring(col001,48,15),
@FirstName=substring(col001,63,10),
@MI=substring(col001,73,1),
@StudentSS=substring(col001,74,9),
@Sex=substring(col001,83,1),
@DOB=substring(col001,84,8),
@StudentID=substring(col001,126,6)
from tblTempData
Insert into tblTAKSAdminInfo
(AdminDate, Grade, ESCRegion, Campus, LastName, FirstName, MI, StudentSS, Sex, DOB, StudentID)
Values
(@AdminDate, @Grade, @ESCRegion, @Campus, @LastName, @FirstName, @MI,
@StudentSS, @Sex, @DOB, @StudentID)
GO
Anyhow I'd appreciate any help.
Code
CREATE PROCEDURE dbo.usp_INS_TAKSData
AS
Declare
@AdminDate Char(4),
@Grade char(2),
@ESCRegion char(2),
@Campus char(3),
@LastName char(15),
@FirstName char(10),
@MI char(1),
@StudentSS char(9),
@Sex char(1),
@DOB char(8),
@StudentID char(6)
select @AdminDate=substring(col001,1,4),
@Grade=Substring(col001,5,2),
@ESCRegion=substring(col001,7,2),
@Campus=substring(col001,123,3),
@LastName=substring(col001,48,15),
@FirstName=substring(col001,63,10),
@MI=substring(col001,73,1),
@StudentSS=substring(col001,74,9),
@Sex=substring(col001,83,1),
@DOB=substring(col001,84,8),
@StudentID=substring(col001,126,6)
from tblTempData
Insert into tblTAKSAdminInfo
(AdminDate, Grade, ESCRegion, Campus, LastName, FirstName, MI, StudentSS, Sex, DOB, StudentID)
Values
(@AdminDate, @Grade, @ESCRegion, @Campus, @LastName, @FirstName, @MI,
@StudentSS, @Sex, @DOB, @StudentID)
GO