Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Schema differences for scalar-valued function

Open
#85 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the issue with the provided SSMS function definition, SqlPackage Extract command, and Microsoft.SqlServer.DacFx comparison using version 162.2.111. Inspect how the scalar-valued function is parsed and represented after extraction, then verify that DeployReport no longer reports drop/create operations for the identical UETrim function and that extraction completes without the TRIM validation error.

Written by the indexing model from the issue text.

Description

bug
  • SqlPackage or DacFx Version: 162.2.111
  • .NET Framework (Windows-only) or .NET Core: net8.0
  • Environment (local platform and source/target platforms): Win11&Server 2019

Steps to Reproduce:
-- SSMS>

USE MASTER;
GO

CREATE DATABASE dacFxRepro;
GO

USE dacFxRepro;
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[UETrim] (@text NVARCHAR(MAX)) RETURNS NVARCHAR(MAX) WITH SCHEMABINDING AS
BEGIN
RETURN (TRIM(NCHAR(0x09) + NCHAR(0x20) + NCHAR(0x0D) + NCHAR(0x0A) FROM @text))
END
GO

-- PS>
-- dotnet tool install --global microsoft.sqlpackage --ignore-failed-sources
-- $server = '.'
-- $database = 'dacFxRepro'
-- $connectionString = "server=$server;database=$database;Integrated Security=true;Connection Timeout=300;Trusted_Connection=True;Encrypt=False;Command Timeout=300"
-- $dacpacPath = '.\dacFxRepro.dacpac'
-- sqlpackage @('/Action:Extract', "/TargetFile:$dacpacPath", "/SourceConnectionString:$connectionString", "/p:IgnoreUserLoginMappings=true")

-- Output:
-- Connecting to database 'dacFxRepro' on server '.'.
-- Extracting schema
-- Extracting schema from database
-- *** Error validating element [dbo].[UETrim]: Incorrect syntax near TRIM.
-- Resolving references in schema model
-- Validating schema model for data package
-- Validating schema
-- Successfully extracted database and saved it to file '...\dacFxRepro.dacpac'.

When trying to compare the dacpac-file to a database using library Microsoft.SqlServer.DacFx, schema differences of function UETrim are reported, although the functions are identical in the database and in the dacpac file.

Same with sqlpackage:
-- PS>
-- $outputPath = 'report.xml'
-- sqlpackage @('/Action:DeployReport ', "/SourceFile:$dacpacPath", "/TargetConnectionString:$connectionString", "/OutputPath:$outputPath")

-- Output
--
--
--
--
--
-- <Item Value="[dbo].[UETrim]"
-- Type="SqlScalarFunction"/>
--
--
-- <Item Value="[dbo].[UETrim]"
-- Type="SqlScalarFunction"/>
--
--
--

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

(DacFx/SqlPackage/SSMS/Azure Data Studio)

Dominant language
GAP
Stars
277
Forks
43
Avg merge
6d 17h
Merged PRs (30d)
3

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.

More from microsoft/SqlScriptDOM

All issues in microsoft/SqlScriptDOM

Similar issues

More Databases issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.