home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 17,802 of 19,505   
   Erland Sommarskog to George Lewycky   
   Re: extracting a query into a text file    
   03 May 10 23:30:46   
   
   050b49cd   
   From: esquel@sommarskog.se   
      
   George Lewycky (gelewyc@nyct.com) writes:   
   > I’m an Oracle transplant to the SQL Server 2008 adjusting and enjoying   
   > many new features but missing some Oracle features I can’t find the   
   > equivalent too.   
   >   
   > One of them being the best “secure” technique to extract a query into   
   > a text file to then be FTP’d to another machine. This will be a daily   
   > scheduled or triggered task.   
   >   
   >   
   > In my Oracle days a simple “spool” command did the trick   
   >   
   > From what I can find so far BCP seems to be best solution, but I’m   
   > trying to keep this in a T-SQL procedure without using the   
   > xp_cmdshell.   
   >   
   >      BCP.EXE "select CustomerID, CompanyName from Northwind..Customers   
   > where   
   >      City='London'" queryout LondonCustomers.csv -c -CACP -t, -T   
   >   
      
   The best solution may be to use SQL Server Integration Services, but   
   I have never used SSIS myself.   
      
   If this is to be scheduled, you could run it from SQL Server Agent as   
   a command-line task that invokes BCP.   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
   SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca