SQLCMD :r <path> where path is a variable
问题 Does the SQLCMD command :r support non-constant literal paths? For example: setvar $(path1) '.\script.sql' :r $(path1) -- SQL01260: A fatal parser error occurred: . :r '$(path1)' -- SQL01260: A fatal parser error occurred: . :r "$(path1)" -- SQL01260: A fatal parser error occurred: . 回答1: Does the SQLCMD command :r support non-constant literal paths? It does. You are defining your variable in a wrong way. Try: :setvar path1 "script.sql" :r $(path1) See also this article on MSDN. 回答2: Just