Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

HOw do I update the another field of table which is not effected by Bulk Insertion . Expand / Collapse
Author
Message
Posted Monday, December 03, 2012 7:52 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, February 21, 2013 3:08 AM
Points: 13, Visits: 53
HI Friends


We want to bulk insert into table table1

Create table table1
{
ID,
ProjectID,
Fname
}

Create view VwName
As
(select Fname from table1)

Create procedure prc_insert
@ProjectID int
As
BEGIN
BULK Insert vwName
FROm 'D:\sample.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = ''
)
END

sample.txt content the comma separated Name of User.

Once I execute the procedure 'prc_insert' it will Insert 'Fname' in table 'table1' ,

How do insert/update ProjectID into table 'table1' , I want to pass same projectID in table for once executing the procedure .

Thanks
Please needful

Post #1391958
Posted Monday, December 03, 2012 8:11 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075, Visits: 4,831
Look at using openrowset and inserting into the table not the view passing in the parameter.

INSERT INTO myTable(ProjectID,FName)
SELECT @ProjectID, FName
FROM OPENROWSET(BULK N'C:\Text1.txt', .....)
GO

http://msdn.microsoft.com/en-us/library/ms190312.aspx




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1391965
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse