Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External file format and external data source changes in the project generate incorrect script #120

Closed
zijchen opened this issue Jul 22, 2022 · 3 comments
Assignees
Labels
area: deployment bug Something isn't working

Comments

@zijchen
Copy link
Member

zijchen commented Jul 22, 2022

Originally submitted as TFS Defect 13100784 by nadebow

The issue was reported by SQL DW customer, but the same issue was repro'ed in SQL DB (SQL DB does not support external file formats, but it supports external data sources and the same issue exists with external data sources) and SQL Server on-prem (external file format and external data source have this issue for on-prem).

More details can be found in VSO - Bug 404161 (External File Format changes generates incorrect script)

SQL DW repro scenario:

  1. Project contains:
CREATE EXTERNAL FILE FORMAT [txt] WITH (
FORMAT_TYPE = DELIMITEDTEXT,
FORMAT_OPTIONS (FIELD_TERMINATOR = N'|', FIRST_ROW = 1, ENCODING = N'UTF8')
);
  1. Update script to FIRST_ROW = 2 and save it.
CREATE EXTERNAL FILE FORMAT [txt] WITH (
FORMAT_TYPE = DELIMITEDTEXT,
FORMAT_OPTIONS (FIELD_TERMINATOR = N'|', FIRST_ROW = 2, ENCODING = N'UTF8')
);
  1. Execute Schema Compare of the Project and Target database that was used to generate the project. Use Generate Script option to generate the update script:
/*

Deployment script for nadebowdw01

This code was generated by a tool.

Changes to this file may cause incorrect behavior and will be lost if

the code is regenerated.

*/

SET

ANSI_NULLS ON;
SET

ANSI_PADDING ON;
SET

ANSI_WARNINGS ON;
SET

ARITHABORT ON;
SET

CONCAT_NULL_YIELDS_NULL ON;
SET

QUOTED_IDENTIFIER ON;
SET

NUMERIC_ROUNDABORT OFF;
 

GO

:setvar DatabaseName "nadebowdw01"

:setvar DefaultFilePrefix "nadebowdw01"

:setvar DefaultDataPath ""

:setvar DefaultLogPath ""

GO

:on error exit

GO

:setvar __IsSqlCmdEnabled "True"

GO

IF

N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'
BEGIN
PRINT N'SQLCMD mode must be enabled to successfully execute this script.';
END
 

GO

PRINT

N'Dropping [txt]...';
 

GO

DROP

EXTERNAL FILE FORMAT [txt];
 

GO

PRINT

N'Creating [txt]...';
 

GO

CREATE

EXTERNAL FILE FORMAT [txt]
WITH (
FORMAT_TYPE = DELIMITEDTEXT,
FORMAT_OPTIONS (FIELD_TERMINATOR = N'|', FIRST_ROW = 2, ENCODING = N'UTF8')
);
 

GO

PRINT

N'Update complete.';
 

GO
  1. Execute generated script results in error.
Msg 33165, Level 16, State 1, Line 46

Cannot drop the external file format 'txt' because it is used by an external table.

** An error was encountered during execution of batch. Exiting.
@zijchen zijchen added the bug Something isn't working label Jul 22, 2022
@zijchen zijchen added this to the 19.2 milestone Jul 26, 2022
@dzsquared dzsquared modified the milestones: 19.2, 19.3 Sep 21, 2022
@SeenaAugusty SeenaAugusty self-assigned this Oct 19, 2022
@dzsquared dzsquared modified the milestones: 19.3, Next Release Oct 26, 2022
@dzsquared
Copy link
Contributor

@SeenaAugusty - I moved this out as we close out the 161.8089.0 release

@toby-freemarket
Copy link

Does that mean this is released?

@dzsquared
Copy link
Contributor

@toby-freemarket this was not completed in the February release, but it is currently targeted for the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: deployment bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants