When I run this select '$(''test'')'in SQL Management Studio 2008, it returns$('test')
select '$(''test'')'
$('test')
When I run sqlcmd -S SERVER -E -d DATABASE -q "select $(''test'')"on the command line, it returnsSqlcmd: Error: Syntax error at line 1 near command '''.
sqlcmd -S SERVER -E -d DATABASE -q "select $(''test'')"
Sqlcmd: Error: Syntax error at line 1 near command '''.
If I remove the dollar sign, it will work. Is "$" a special character?
Is this sqlcmd error? How can I modify the script to get the desired result.
Yes, it $(id)has special semantics in SQLCMD: it is a variable substitution. You can run commands, for example:
$(id)
sqlcmd /E /S . /v variable=MyTable /Q "select * from $(variable)"
MyTable. , /v - . SSMS, , SQL . SSMS , " SQLCMD".
/v
. sqlcmd .
, :
select $('test')
. , "$", :
select ('test')
, , ", :
"
select '$(test)'
:
sqlcmd -S SERVER -E -d DATABASE -q "select ''$(test)''"
Source: https://habr.com/ru/post/1737401/More articles:Are there Phen-Wise comparisons for the Chi-Square test in R? - rR is looking for the wrong version of java - javaHow to make the controller change its behavior depending on the type? - language-agnosticscreenshots of closed / minimized windows - c ++Alternating Richfaces DataTable Row Color - cssunordered lists as columns - cssHow can I switch time zones in Perl Template :: Plugin :: Date? - timezonehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1737404/how-to-pass-additional-convert-options-to-paperclip-on-heroku&usg=ALkJrhi6vfThDs3GyTxHrHIW03i8tFckpAThe problem with full-text search - sql-serverRemoving noise words in SQL Server 2005 full-text indexing - sql-server-2005All Articles