Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 668495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:02:47+00:00 2026-05-14T00:02:47+00:00

I am faced with an interesting problem and I am not even sure if

  • 0

I am faced with an interesting problem and I am not even sure if it is possible:

I need to create a Stored Procedure in SQL Server 2008 that when executed does the following:

  1. Executes a Batch file – located on the SQL Server (i.e. C:\Mybatchfile.bat) – This Batch file will output a single text file to a directory on the SQL Server (i.e. C:\Output\BatchFileOutput1.txt).

  2. Bulk Insert the contents of the text file into table within my database.

  3. Deletes the text file from the server.

Before I really start digging into how to achieve this, is this even possible?

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:02:47+00:00Added an answer on May 14, 2026 at 12:02 am

    You should be able to put all of this in one procedure:

    1) to execute the batch file use: xp_cmdshell (Transact-SQL). However, many consider this a security risk, and access to it may not be enabled within the database. You could use a CLR to execute the batch file, which would be more secure.

    2) you can use the bcp Utility to copy the rows into a table.

    3) you would use the method from #1 to delete the file. Either issue the delete command from the xp_cmdshell, which is a security risk. Or create a CLR where you pass in the file name to delete the file. I would not allow the path to be passed in, hard code that, so only files in your “special” directory can be deleted and not C:\, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today we faced a quite simple problem that were made even simpler by the
I recently faced a problem of presenting the output of simple genetic algorithm that
Currently im faced with the following problem: I have a script that searches through
Even though I know that, at least to my knowledge, this is not the
Here's an interesting problem. I have an ETL script written in c# that I
I faced a little trouble - I do not know if I can define
I have faced this problem quite often during the last couple of months, during
I am currently faced with a difficult sorting problem. I have a collection of
Here I am faced with an issue that I believe(or at least hope) was
We have recently been faced with the problem of porting our C++ framework to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.