Find Jobs
Hire Freelancers

Write a stored procedure SQL 2012

$10-30 USD

Completed
Posted over 8 years ago

$10-30 USD

Paid on delivery
I have a stored procedure that BULK INSERTs some data from a csv file to a table. There are many different tables so the sproc picks up the tablename and csv file format and filename as input parameters to upload the data. Pertinent part of the code SET @sql = 'BULK INSERT '+@DestTableName+' FROM ''' + @LoadDataFileName + ''' WITH (FORMATFILE='''+@LoadFormatFileName+''')'; EXEC(@sql); I now want to add an intermediate audit table to this, so I have an audit of which rows were inserted and which rows 'failed' the insert. The audit tables will have the same structure as the original tables plus a few extra fields like, UploadID, Auditdtae datetime default getdate(), Loginname default suser_sname, UploadSuccess Yes/No. The sproc should check first if the audit table exist or not as the Audit table name will be +@DestTableName + '_Audit'. If it does not exist the sproc will create it. Process 1. BULKINSERT all the data to the Audit table (generating the next UploadID value (INTEGER)). 2. Cursor your way through all the rows of this UploadID and TRY/CATCH INSERT into the actual table. 3. If successfully inserted, then Mark the audit table row as UploadSuccess as Yes 4. If row fails to insert, then Mark the audit table row as UploadSuccess as No I hope this is clear. Thanks Aasim
Project ID: 8915642

About the project

7 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
A proposal has not yet been provided
$25 USD in 1 day
5.0 (12 reviews)
4.3
4.3
7 freelancers are bidding on average $35 USD for this job
User Avatar
Hi there, I have written VERY similar MS SQL scripts. I can help you edit it to include the intermediate (audit) table. It will be coded with utmost clarity in mind. Thank you, Goran
$55 USD in 1 day
5.0 (1 review)
2.5
2.5
User Avatar
A proposal has not yet been provided
$50 USD in 2 days
5.0 (1 review)
2.0
2.0
User Avatar
This is something I have done before and feel very comfortable in doing. I have 8 years of experience in doing SQL Server writing queries and Stored Procedures.
$25 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
Hi Sir! I'm Eliot,, and I can help you creating the process on your stored procedure for handling audit tables. Please let me know if Interested, Best regards. Eliot
$30 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
A proposal has not yet been provided
$35 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED KINGDOM
London, United Kingdom
5.0
29
Payment method verified
Member since Jul 15, 2005

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.