简体   繁体   中英

VS Database project Error with %%physloc%%

I am receiving the following error from a SQL Server(2014) database project on VS2012: Error SQL46010: Incorrect syntax near %.

And this is the code giving the error:

SELECT distinct sys.fn_PhysLocFormatter(C.%%physloc%%) as id
FROM T_Customer C

The query runs just fine in SQL Server, but I want to get rid of the error in VS to be able to compile the whole project.

This is a risk you take when you use undocumented syntax.

The SSDT parser will be expecting an identifier there. The column name isn't quoted it so the grammar demands that it should meet the rules for regular identifiers or be one of a few documented exceptions (eg $identity , $rowguid )

You won't be able to build the project unless you change the stored proc to not use that syntax or hide it from the parser (eg inside an EXEC ).

I recommend rewriting to not use the syntax. It is extremely unlikely that the approach shown in the question is going to be a good solution to anything. Chances are that it won't work as desired in the face of concurrent writes causing row movement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM