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

  • Home
  • SEARCH
  • 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

I faced an interesting problem today. I have 4 strings which I need to
I faced a problem - I need to use a macro value both as
I faced a very wierd problem that in my db i set my id
I faced a problem in Visual studio 2008.When i click on Sorce Control Explorer(Views->
Even though I know that, at least to my knowledge, this is not the
today I faced with very interesting problem. When I try to rewrite xml file.
I faced an interesting problem as... I have MSSQL (2005) table A which contains
I faced a very interesting situation and do not know how to resolve it.
Background / Problem I'm trying to create a reusable JSF composite component that can
I faced a very interesting fact, and hope you have an answer for that.

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.