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 6251331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:35:40+00:00 2026-05-24T13:35:40+00:00

USE [PreMfg] GO /****** Object: StoredProcedure [dbo].[procAddOrderItem] Script Date: 08/11/2011 10:28:21 ******/ SET ANSI_NULLS

  • 0
USE [PreMfg]
GO
/****** Object:  StoredProcedure [dbo].[procAddOrderItem]    Script Date: 08/11/2011 10:28:21     ******/
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[procExcelQuotebyItem] 

(   
      @OrderNumber INT
)
AS

BEGIN

SET NOCOUNT ON

DECLARE @Cmd varchar(1000)
DECLARE @fn varchar(500)
DECLARE @provider varchar(100)
DECLARE @ExcelString varchar(100)

--  New File Name to be created

SET @fn = '"D:\Pre-Manufacturing\Quote by Item.xls"'

--  FileCopy command string formation

SELECT @Cmd = 'Copy "D:\Pre-Manufacturing\Quote by Item (Excel) Template.xls" ' + @fn

--  FielCopy command execution through Shell Command

EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT

    SET @provider = 'Microsoft.Jet.OLEDB.4.0'
    SET @ExcelString = 'Excel 8.0;Database=' + @fn

--  Executing the OPENROWSET Command for copying the select contents to Excel sheet.

exec('INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT [ITEM NUMBER],[PHOTO],[DESCRIPTION],[CASE PACK],[PIECE PRICE],[CASE PRICE],[WT],[CUBE],[OUTSIDE CASE DIMENSIONS],[UPC#],[CASE UPC#] FROM [Sheet1$]'') 
SELECT [ItemNumber],''' + ' ' + ''',[Item_Description],[Casepack],[Unit Price],[Case Price],[Weight],[Cube],[Case Dims],[UPC],[Case UPC] FROM [Order Summery] WHERE [Order #] = ' + @OrderNumber + '')

SET NOCOUNT OFF

END

USE [PreMfg]
GO
/****** Object:  StoredProcedure [dbo].[procAddOrderItem]    Script Date: 08/11/2011 10:28:21 ******/
SET ANSI_NULLS ON
SET ANSI_WARNINGS ON

GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[procExcelQuotebyItem] 
(
    @OrderNumber INT
)
AS

BEGIN
SET NOCOUNT ON


DECLARE @Cmd varchar(1000)
DECLARE @fn varchar(500)
DECLARE @provider varchar(100)
DECLARE @ExcelString varchar(100)
DECLARE @SendMail varchar(100)

--  New File Name to be created
    SET @fn = 'D:\Pre-Manufacturing\QuotebyItem.xls'


--  FileCopy command string formation
    SET @Cmd = 'Copy D:\Pre-Manufacturing\QuotebyItemTemplate.xls ' + @fn

--  FileCopy command execution through Shell Command
    EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT

--  Mentioning the excel destination filename
    SET @provider = 'Microsoft.Jet.OLEDB.4.0'
    SET @ExcelString = 'Excel 8.0;Database=' + @fn

    EXEC('INSERT INTO OPENROWSET(''' + @provider + ''',''' + @ExcelString + ''',''SELECT * FROM [Sheet1$A2:K2]'') 
    SELECT [ITEMNUMBER],[ORDER #],[ITEM_DESCRIPTION],[CASEPACK],[UNIT PRICE],[CASE PRICE],[WEIGHT],[CUBE],[CASE DIMS],[UPC],[CASE UPC] FROM [ORDER SUMMERY] WHERE [Order #] = ''' + @OrderNumber + '''')

    /* Attach the file to an email and send (the sp_send_dbmail won't accept variables in the arguments, so you have to build it with some double quotes first, then exec the whole string*/

    EXEC msdb.dbo.sp_send_dbmail 
    @recipients= 'user@domain.com', 
    @subject = 'Auto-Generated Quote by Item Report', 
    @body = 'Quote by Item Report attached', 
    @body_format = 'HTML', 
    @file_attachments = @fn

    /*Cleanup*/

    SET @Cmd = 'DEL ' + @fn
    EXEC xp_cmdshell @Cmd, no_output

    SET NOCOUNT OFF
END
  • 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-24T13:35:40+00:00Added an answer on May 24, 2026 at 1:35 pm

    Try changing:

    SET @ExcelString = 'Excel 8.0;Database=' + @fn

    to:

    SET @ExcelString = 'Excel 8.0;Data Source=' + @fn +';'

    Not 100% sure on the trailing semi-colon so try it with and without

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

Sidebar

Related Questions

USE [Fk_Test2] GO /****** Object: Table [dbo].[Owners] Script Date: 08/20/2010 16:52:44 ******/ SET ANSI_NULLS
My use case is simple. I have a root domain object which references a
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
We use a data acquisition card to take readings from a device that increases
I use Firebug and the Mozilla JS console heavily, but every now and then
I use rsync to synchronize files to Windows clients in a server agnostic way.
I use emacs to edit my xml files (nxml-mode) and the files were generated
I use the VS2008 command prompt for builds, TFS access etc. and the cygwin

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.