microsoft / microsoft/DacFx

Import fails when target has the collation set and importing data with ASCII values

Open
#299 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement triaged
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

- SqlPackage or DacFx Version: All
- .NET Framework (Windows-only) or .NET Core: Both
- Environment (local platform and source/target platforms): Any

SqlPackage do not provide any parameter to modify or handle target database collation. Only workaround is to increase the length of the source table column and get an export to import to the different collation databases. Verify ICM: 397401962 for the issue. We need to check if this can be fixed or not.

**Steps to Reproduce:**

Source database:
1. Create a database with default collation.
2. Create a table `CREATE TABLE [dbo].[my_table](
[id] [int] IDENTITY(1,1) NOT NULL,
[txt] [varchar](10) NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]`
3. Add sample data `SET IDENTITY_INSERT [dbo].[my_table] ON
GO
INSERT [dbo].[my_table] ([id], [txt]) VALUES (1, N'ABCDEFGZ')
GO
INSERT [dbo].[my_table] ([id], [txt]) VALUES (2, N'ABCDEFGé')
GO
SET IDENTITY_INSERT [dbo].[my_table] OFF
`
4. Export bacpac.

Target database:

1. Create database with collation "Latin1_General_100_CI_AS_SC_UTF8".
2. Import bacpac and it fails.
![image](https://github.com/microsoft/DacFx/assets/74571829/a1febacd-0eb0-45a4-a499-7fef14c8c8fd)

**Did this occur in prior versions? If not - which version(s) did it work in?**

(DacFx/SqlPackage/SSMS/Azure Data Studio)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the bacpac import with the provided table, ASCII and accented values, and the Latin1_General_100_CI_AS_SC_UTF8 target collation using SqlPackage or DacFx. Trace the import failure and determine whether the behavior can be corrected; done means the sample bacpac imports successfully or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.