-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to use SqlCmdVariable in views MSBuild.Sdk.SqlProj #600
Comments
I would kind of expect that to work. Can you share the error message and a small repro for this so that we can investigate? |
Thanks for checking. Below is the error. I will also upload a repo and let you know. Basically it doesn't fid the variable 1>C:\SourceCode\lqd-dwh-database\TestDb\Stored Procedures\InsertTest.sql(3,39): error SQL71561: View: [dbo].[Test] has an unresolved reference to object [$(QrmDatabaseName)].[Master].[Qrm]. But when it has stored procedure it finds it correctly |
Not sure what's going on just yet without a repro, but based on the above logs in your first scenario it seems that no value is passed for the |
Appreciate your help on this Jonathan. Please see below the repo I have created in Github for replicating this issue https://github.com/sunnylnct007/sdkstyledbproject |
@sunnylnct007 You need to use project (or .dacpac) references I think, have a look at the readme |
Thanks Eric but that is not the issue here. The issue is the variable replacement not happening for views. If you want I can add the dacpac but that's not going to make it any better. |
I think the parsing of stored procedures is less strict than view definitions. So I think the sproc is also not parsing on a live deployment |
I'm starting to think this is actually a limitation of DacFx, not necessarily of MSBuild.Sdk.SqlProj. See https://stackoverflow.com/questions/12161392/using-ssdt-how-do-i-resolve-sql71561-errors-when-i-have-a-view-that-references for example. Might want to file an issue over at https://github.com/microsoft/dacfx/issues. |
Hi, I am migrating database projects to use MSBuild.Sdk.SqlProj. I am unable to use SqlCmdVariable in views. They work fine in stored procedures.
Below works
CREATE PROCEDURE Test AS
BEGIN
Select count(*) as CountTest from [$(QrmDatabaseName)].[Master].[Qrm] qrm
END
Below doesn''t work
CREATE VIEW Test AS
Select count(*) as CountTest from [$(QrmDatabaseName)].[Master].[Qrm] qrm
Can you please let me know if this is expected behaviour?
The text was updated successfully, but these errors were encountered: