Search code examples
sql-servervisual-studio-2015sql-server-data-toolssqlclr

SQL 71501 has an unresolved assembly reference


We are using SSDT tools with Visual Studio 2015 and Target Platform set to SQL Server 2008. We are stuck with this function which is throwing an error and need assistance on what we can do to fix it.

SQL71501: Function: [dbo].[GetFormattedAddress] has an unresolved reference to Assembly [AddressFormatting]

CREATE FUNCTION [dbo].[GetFormattedAddress]
(@AddressID INT, @CompleteAddress BIT)
RETURNS NVARCHAR (4000)
AS
EXTERNAL NAME [AddressFormatting].[AddressFormatting.UserDefinedFunctions].[GetFormattedAddress]
GO

--UPDATE

Under the Assemblies folder, for AddressFormatting.dll, I set the BuildAction to Build and then under the References I managed to see the Model Aware property which I have now set to True. After this now I get the following error:

SQL46010: Incorrect syntax near

enter image description here

The file where it's pointing the error is AddressFormatting.dll


Solution

  • I also had this issue and it was resolved mysteriously by changing the SQL compatiblity level in Visual Studio to 2012, recompiling the project and then changing it back to compatibility level of 2008 and then do a clean project and then recompile.