SqlScriptDOM
SqlScriptDOM copied to clipboard
Schema differences for scalar-valued function
- 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 -- --<DeploymentReport xmlns="http://schemas.microsoft.com/sqlserver/dac/DeployReport/2012/02"> -- <Alerts/> -- <Operations> -- <Operation Name="Drop"> -- <Item Value="[dbo].[UETrim]" -- Type="SqlScalarFunction"/> -- </Operation> -- <Operation Name="Create"> -- <Item Value="[dbo].[UETrim]" -- Type="SqlScalarFunction"/> -- </Operation> -- </Operations> --</DeploymentReport>
Did this occur in prior versions? If not - which version(s) did it work in? Yes.
(DacFx/SqlPackage/SSMS/Azure Data Studio)