Procedure to save the output of a query into excel file or flat file

Procedure to save the output of a query into excel file or flat file
I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
I have run the query --
DECLARE @cmd VARCHAR(255)
SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
Exec xp_cmdshell @cmd
error message--
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
NULL
Goel.Aman

Hello,
-T:
Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
login_id, and password are not required. If
–T is not specified, you need to specify
–U and –P to successfully log in.
-U:
Specifies the login ID used to connect to SQL Server.
Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
-T option (trusted connection) instead of the
user name and password combination
I would suggest you take a look at the following article:
bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
A similar thread regarding this issue:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
Regards,
Elvis Long
TechNet Community Support

Similar Messages

  • Exporting the results of a query into excel

    Hi,
    Here's my code for exporting a cfm page into a spreadsheet:
    <cfsetting enablecfoutputonly="Yes">
    <cfcontent type="application/msexcel">
    <cfheader name="Content - Disposition" value="filename=myReport.xls">
    <cfquery name="getInfo" datasource="#dsn#">
    SELECT      id, fname, lname, orgname, email, phone, topic, synopsis, pdf, expertise, fiscal_year, date_added
    FROM         table
    </cfquery>
    <table border="1" cellspacing="1">
    <tr>
    <td>EFRI 2011 Submissions (Total Submissions: <cfoutput>#getInfo.recordcount#</cfoutput>)</td>
    </tr>
    <tr>
    <td>Record Number:</td><td>Last Name</td><td>First Name</td><td>E-mail</td>
        <td>Phone</td>
        <td>Organization</td>
    <td>Expertise</td>
    </tr>
    <cfoutput query="getInfo">
    <tr>
    <td>#currentRow#. #lname#</td>
    <td>#fname#</td>
        <td>#email#</td>
        <td>#phone#</td>
        <td>#orgname#</td>
    <td>#expertise#</td>
    </tr>
    </cfoutput>
    </table>
    and here's the error that I'm getting.  What is wrong with the code?
    500
    Corrupt form data: no leading boundary:  != -----------------------------7d96c1140276
    java.io.IOException: Corrupt form data: no leading boundary:  != -----------------------------7d96c1140276
         at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:174)
         at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:93)
         at coldfusion.filter.FormScope.fillMultipart(FormScope.java:136)
         at coldfusion.filter.FusionContext.SymTab_initForRequest(FusionContext.java:428)
         at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:33)
         at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
         at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)
         at coldfusion.CfmServlet.service(CfmServlet.java:175)
         at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
         at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
         at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
         at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
         at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
         at jrun.servlet.FilterChain.service(FilterChain.java:101)
         at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
         at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
         at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284)
         at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
         at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
         at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
         at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

    try this
    <cfsetting showdebugoutput="false">
    <cfcontent type="application/msexcel">
    <cfheader name="Content-Disposition" value="attachment; filename=myReport.xls">  

  • How to save the output of a concurrent proram automatically

    Hi Friends,
    We have a requirement to save the output of a concurrent program to a specific folder for a reporting purpose. whenever we run that concurrent program it should save the out file in the network folder \\out_files\con_prg like that
    instead of storing it in its default folder in unix.(or I should recoganize which out file is for my concurrent program from the default folder and to move it to windows shared network folder). If it is one time , I can do it manually. But I need to schedule that concurrent program to run every day and transfer the output to the windows folder.
    Our system is Oracle Apps 11i , Data base 9i in Solaris.
    If you have any idea or sugesstion for this , please share it with me here.
    Thanks in advance,
    Vimal...

    Hi
    Thanks for the reply. I can get the name from the fnd_concurrent_requests table, But how can I identify which is the one submitted by me. Because there is possibility of multiple submission by the users with different parameters.
    I can give you more details.
    We are having a BI report (not oracle) for AR Aging Report details. It has a staging table to get the data from Oracle EBS.
    My job is to run Our Customized AR Aging Report with 2 different parameters like sysdate and the same date for last month.
    Get the output file and processs it (for this we are using VB Script) to populate the staging table from where the BI report get the data.
    So far I am doing this manually for more than a month.
    The Users wants to have all the above mentioned process to be combined as a single concurrent program , so that they can submit easily and populate the data any time of the day like other Oracle Standard reports.
    The BI report can be viewed any time of the day by more than 15 users and also AR Aging report can be run so many times in a day by another set of users.
    In this situation how can I get the exact output file of the request submitted by me.
    Thanks,
    Vimal...

  • How to execute a procedure depending on the result of a query?

    Hello, I'm new in ODI.
    I want to execute a procedure depending on the result of a query Oracle table.
    We have a Oracle Table whit a column that contains two possibles values.
    I want read the table, row by row, and depending on this value, execute a Procedure or execute another.
    How can i do?

    what you need to do is
    1. create a variable which "new_var2" which has the count of the number of rows you want to process. must be data type numeric.
    2. copy "new_var2" to the package screen.
    3. duplicate the "new_var2" on the package screen and evaluate the variable and test for "> 0" zero, call it "new_var2_E"
    3. create a new odi variable "new_var1" with a refresh of "select field1 fom (select field1,rownum as rownumber from tablex) where rownumber = #new_var2" in the relevant schema and technology.
    4. copy "new_var1" into your package (some where in the flow)
    5. right click the "new_var1" variable in you package screen and you should get the option duplicate step (click on that)
    6. select the the duplicate "new_var1" on the package screen and correct the the name to something meaning full to you "new_var1_E", also change the "type" to "evaluate variable" then you should see a "value" box. enter one of the values you want to test in the box (remember do not put in quotes ' )
    7. now back on the package screen join the "new_var1" to the "new_var1_E" with an OK line
    8 you now join "new_var2" to "new_var2_E" with OK
    9 you join "new_var2_E" to "new_var1"
    10. you then join the "new_var1_E" with an OK or a KO line to the relevant procedure.
    12. you need to duplicate "new_var2" in the package screen one more time this time and call it "new_var2_D" set the type to evaluate and then select the increment of -1
    13. the relevant procedure to "new_var2_D" with an OK
    14. join the "new_var2_D" to the "new_var2_E" with an OK
    15. this should close off the loop now the exit point is "new_var2_E" with a KO line to the next part of your process....
    Basically you should end up with a loop on new_var2 decementing, and it is used to get a specific next record row from your table.
    Hope this helps, sorry it is a little long winded..
    Edited by: DavidGD on Feb 8, 2009 3:29 PM

  • How to save the output of sap script to pdf document in sap

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms

    Hi deepika,
    This thread will solve ur problem OTF  -> PDF
    Regards,
    Pravin

  • How to save the output of sap script in sap so that can be retrieved later

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:01 AM

    Hi Deepika,
    Look into this link https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/401cca81-b861-2910-ada2-f416dfb3b3fe
    Regards,
    Pravin

  • Spooling the output of a Query with out displaying the rows

    Hello All,
    Is it possible to spool the output of
    a query/dbms_output.put_line with out displaying
    the Query output on the console.
    In my case,list of rows in the output is huge, I want
    to eliminate displaying the output of query
    so that spooling will complete faster.
    Thanks in advance.
    -Srini

    You can do:
    SET TERMOUT OFFIn your script before doing the spool command.
    You will have to write your query as a .SQL script and run it from SQL*Plus in order for it to work the way you expect.
    sqlplus -s username/password @query_script.SQL

  • Get the output of a query in a textpad..

    Hi..
    I need to get the output of a query in a notepad..
    Can anyone help me..

    spool c:\emp.txt
    fire select * from emp;
    spool off;
    go to c: and check your text file.
    hare krishna
    Alok

  • How to save the output of report program??

    Hello Everbody,
    I want to save the output of a report program(i.e list),how can i do this???which function module should i use to achieve this???
    Thanx in advance.

    <b>data: list like abaplist occurs 0 with header line.
    data: begin of listout occurs 0,   
      line(1024) type c,   
      end of listout.
    do 100 times.
      write:/ sy-index.enddo.
    call function 'SAVE_LIST'
    EXPORTING*
    LIST_INDEX               = '0'
    tables 
      listobject    = list
    exceptions 
    list_index_invalid       = 1  
    others                   = 2          .
    call function 'LIST_TO_ASCI'    
    tables         
    listobject         = list    
    listasci           = listout 
       exceptions      
       empty_list         = 1    
       list_index_invalid = 2    
        others             = 3.
    call function 'GUI_DOWNLOAD' 
       exporting   
          filename = 'C:\Test.txt'  
      tables    
         data_tab = listout.</b>

  • How to write code to print and save the output in my GUI?

    I had been searching on code to program print and save commands to print and save the output from the GUI but to no avail. Can someone help me?

    The output will be link from the previous GUI page. Hence the output is a page with Jtable and a button for print to print the information in the JTable.

  • Schedule webi document to printer and save the output in shared drive

    Hi all,
    Is it possible to schedule a webi document via java BOE SDK, run at once, save the output in pdf format in a shared drive and at the same time, send the output to printer? Or I need to run the webi document to run 2 times? Thanks.
    Best regards,
    Grace

    Hi Adam,
    How about can I schedule a webi document to printer only? In Crystal report, I can do this but seems for webi, no such function?
    Best regards,
    Grace

  • I am using both PSE 13 and Lightroom 5.  When I use Lightroom as an external editor and save the photo, it shows up in PSE13 as an edited file but does not look any different.  Why doesn't it appear edited?

    I am using both PSE 13 and Lightroom 5.  When I use Lightroom as an external editor and save the photo, it shows up in PSE13 as an edited file but does not look any different.  Why doesn't it appear edited?

    People who have Photoshop, but don't have Lightroom, need ACR so that they can use Raw files. Without ACR they could do nothing with those (they may also like having ACR so that they can work on other kinds of image using the same kinds of adjustments and techniques, as are used with Raw files).
    People who have Lightroom, can get access to Raw files regardless whether ACR is present or not. They can use Lightroom on other kinds of image also, using the same methods. LR can pass images directly into Photoshop without passing via ACR (or else does so transparently, which amounts to substantially the same thing).
    ACR does not, strictly speaking, even need to be installed for this external editing to happen. In fact, not even PS needs to be - since a different image editor can be used instead, while still retaining the Adobe Raw conversion etc.
    Lightroom "subcontracts out" specialised external tasks, in this workflow, but is still your "main contractor": the image is otherwise located, viewed, managed, adjusted/presented and output entirely using LR.
    So IMO we can divide image processing into:
    operations that involve pixels and layers and layer masks and adjustment layers etc (of the kind done inside Photoshop)
    operations that involve parametric edits (of the kind done in ACR where you are not using a Lightroom based workflow; otherwise, done inside Lightroom)
    When PS is called in, that's because those tasks are impossible or unsuitable to do in Lightroom. But those tasks can't be done in ACR either - by definition, since LR and ACR have exactly the same image processing "feature set".
    Lightroom is irrelevant to the Bridge + ACR + PS workflow. This workflow requires both your PS and your ACR to be current enough, to support your Raw format etc.
    ACR and Bridge are irrelevant to the LR + (image editor) workflow. It is in this case, only LR which needs to be current enough to support your Raw format etc.
    RP

  • How to save the image after converting it into 64RGB

    Hello every one,
    I am trying to save the output image of 64RGB on my computer. Is this possible? I had a go and could not do it. Can some one look at my code please. 
    Regards,
    Lazer
    Solved!
    Go to Solution.
    Attachments:
    Save 64 RGB image.vi ‏91 KB
    1800s.jpg ‏8 KB

    Have a look at the following:
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • How to down load the output of smart form into .XLS(spreadsheet) File.

    Hi All,
    We have one requirement like we need to down load the output of smart form into .XLS(spreadsheet) File.
    This output is related to Shipment(VT03N) in the output we are not displaying the any logo.
    Just we are displaying the address and item detail.
    Anyone tell me, If possible please let me know how can solve that problem.
    Thanks and regards,
    Amjad Hussain,

    Hi Mohammed,
    Absolutly you can download output from smartforms to excel.
    After execution of  your Smartforms in that layout Menu bar Do below  navigation.
    GoTo =>  ListDisplay      after that
    System  =>   List
                            =>    Save
                                             => Local File
                                                               => Spread Sheet.
    if helpful REWARD points
    Thank you .
    Regards
    Ramana

  • How to write the output of a mapping into a file (OWB10.2

    Hi
    I am using Oracle 10.2.0.1 version of OWB.
    the task is to write the output of a mapping into a File (Flat File).
    Please help me out!
    Regards
    Abi

    Hi,
    Create the file format thru OWB and mention the location in OWB. Deploy the file and it will be ready to use for target load. Make sure the connection to the target loc is available.
    Regards
    Bharadwaj Hari

Maybe you are looking for