Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-02-26 : 09:13:54
|
| Suhas writes "Hi,I am using DTS (MS SQL Server 7.0) to run a query that would output data to a text file, but got the following error message: "Incomplete file format information - file cannot be opened".Here is my query:DECLARE @GMTOffset integerSELECT @GMTOffset = 6 * 3600 SELECT a.PartnerKEY, a.DocumentName, a.FunctionalGroupId, a.TransactionSetId, a.ComplianceStatus as ASNComplianceStatus, dateadd(second,(a.TimeCreated - @GMTOffset),'1/1/1970') as ASNTimeCreated, a.ReferenceData, b.AckStatus, dateadd(second,(b.AckTime - @GMTOffset),'1/1/1970') as FAAckTime, b.DocumentControlNumber as ASNSTControlNumber, b.GroupControlNumber as ASNGSControlNumber, b.InterchangeControlNumber as ASNISAControlNumberINTO ##ASNInfoFROM Document_tb a, Track_tb bWHERE a.DocumentKEY = b.DocumentKEYAND a.Direction = 1AND a.TransactionSetId = '856'AND a.LocationStatus = 1AND a.TestMode = 0;SELECT a.*, b.ComplianceStatus as FAComplianceStatus, c.DocumentControlNumber as FASTControlNumber, c.GroupControlNumber as FAGSControlNumber, c.InterchangeControlNumber as FAISAControlNumber, dateadd(second,(b.TimeCreated - @GMTOffset),'1/1/1970') as FATimeCreatedINTO ##ASNFAInfoFROM ##ASNInfo a, Document_tb b, Track_tb cWHERE a.ASNGSControlNumber = b.ReferenceDataAND a.FunctionalGroupId = b.DocumentNameAND a.PartnerKEY = b.PartnerKEYAND b.DocumentKEY = c.DocumentKEYAND b.DocumentName = 'SH'AND b.Direction = 0AND b.TransactionSetId = '997'AND b.LocationStatus = 0AND b.TestMode = 0;SELECT a.*FROM ##ASNFAInfo a;I am not quite sure why it is failing (I have tried using a global temp table, since I am accessing data across multiple steps). Also, can I use bcp to run this query? How?Any suggestions?Thanks,SuhasPS: I am choosing the "source" as: Microsoft OLE DB Provider for SQL Server" & my "destination" is a comma delimited text file." |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-02-26 : 10:00:27
|
| Easier just to put it all in a stored procedure.Given that you have create a global temp table then something like this at the end of the SP before dropping the tables.exec master..cmdshell('bcp dbname..##ASNFAInfo out c:\mytext.txt -Ssvrname -Uusrname -Ppassword -c')Try it first on just a fixed table to get it working.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|