6

I don't consider "just to ensure that sqlcmd-mode is not required by a script" a valid reason.

Any things to think of before giving the order to enable this setting to my coworkers?

Nick Chammas
14.8k17 gold badges77 silver badges124 bronze badges
asked Oct 31, 2011 at 7:42
0

2 Answers 2

9

Yes, I don't want to work in SQLCMD mode all the time
It suits you but not me

Irritating:

Enabling SQLCMD mode turns off IntelliSense and the Transact-SQL debugger in the Database Engine Query Editor.

Dangerous?

When executed from the command line, the sqlcmd utility permits full interaction with the operating system. When you use the Query Editor in SQLCMD Mode, you must be careful not to execute interactive statements. The Query Editor cannot respond to operating system prompts.

And some limitations of course...

So no flow control or TSQL variable assignments with SQLCMD mode? This is a big disappointment. Not very many SQLCMD keywords are supported and no real flow control commands

answered Oct 31, 2011 at 12:18
1
  • Regarding your dangerous statement, it makes me wonder if there is a way to automate running SQL scripts from the command line with SQLCMD mode disabled? Commented Aug 3, 2020 at 16:54
2

It's good, and I'd say you can safely recommend it to people.

I would only be wary about the way that people start using it as an alternative to Dynamic SQL. I see people use SQLCmd variables $(somevar) instead of using SQL variables @somevar, which can hurt queries somewhat. But on the whole, there are plenty of good things about SQLCmd mode, and if you're pointing out the odd drawback like this, then I'd suggest you should be fine recommending it.

"Order" might be a bit strong though. ;)

answered Oct 31, 2011 at 12:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.