.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
-- 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")
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 --<?xml version="1.0" encoding="utf-8"?> --
--
--
--
-- <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)