none
SQL Server Import Export Wizard executing but not writing rows to file

    问题

  • I am trying to export data from a database using the export wizard. My destination is a delimited flat file with a custom text qualifier(^`~) because the data in one of the fields I am exporting may contain basically every character known to man. So I am able to set up the query in the wizard just fine, and it executes with 0 errors, everything's good. But it shows that it has written no records to the destination file. Now, I know my query returns records, but it is somewhat of a multistep query. It goes something like this:

    DECLARE @RecordCount AS INT SET @RecordCount = SELECT COUNT(*) FROM SomeTable WHERE COLUMN1 = 1 AND COLUMN2 = 2

    DECLARE @TempTable AS TABLE( COLUMN1 INT, COLUMN2 INT, COLUMN3 VARCHAR(255)) INSERT INTO @TempTable SELECT Column1, Column2, Column3, Column4 FROM SomeOtherTable WHERE Column1 IN (--Sub Query that gets a random list of ids)

    SELECT TOP(@RecordCount) A.COLUMN1, A.COLUMN2, A.COLUMN3, A.COLUMN4, B.COLUMN1, B.COLUMN2, B.COLUMN3 FROM @TempTable A INNER JOIN JoinTable B ON A.COLUMN1 = B.COLUMN1 ORDER BY COLUMN1

    Like I said, the query works just fine when run in Ssms, it's only when using the export wizard that I have the issue of it not actually writing any rows to the destination. I would simply save the query results as a csv, but the comma delimiter is not possible for me because of the data in the fields, which is why I need the export wizard to declare a custom text qualifier. Can anyone point me in the right direction? Thanks :)

    2012年3月15日 15:06

答案

全部回复