Command line start ssms with localdb does not work - ssms

I have a requirement to start ssms (SQL Management Studio) from the command line that connects to a (localdb)\myinstance. The instance exists
sqllocaldb info myinstance
but using the command line and the -S parameter with (localdb)\myinstance throws an error.
PS C:\workingArea> ssms -S(localdb)\myinstance
localdb : The term 'localdb' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:9
+ ssms -S(localdb)\myinstance
I can connect using the named pipe but would ideally like to use the known name.

You can try the following: ssms -S LOCALHOST\myinstanceto connect to a LocalDb instance

Related

The term 'Get-AzureSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program

I installed Az Module with the following command, but I still get the following error.
Install-Module -Name Az -AllowClobber -Scope AllUsers
Get-AzureSubscription: The term 'Get-AzureSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Any ideas?
The command to get the subscription is Get-AzSubscription.
Most Azure commands include Az, not Azure.
You might need to login first with Connect-AzAccount, and logging in through the browser popup.
Sign in with Azure Powershell - Microsoft
Get-AzSubscription no longer works. Use Get-AzureRmSubscription to retrieve your Azure Subscription details.

CommandLine Execution from SQL Server not finding CMD variable

I am trying to get a SQL Server Agent job to execute in command line the following code. It sets the variable to the server name of the SQL Server instance so that it can reach out to the UNC path and run the executable. This singular line works find when I run it on the server in command line through RDP, but fails when run in SQL Server as type Operating system (CmdExec). The line is:
FOR /F "usebackq" %i IN (`hostname`) DO SET _exeCall=\\%i\test\test1.exe && %_exeCall%
The results from the log are:
C:\Windows\system32>SET _exeCall=\\testbox\test\test1.exe && _exeCall
'%_exeCall%' is not recognized as an internal or external command,
operable program or batch file.
The machine is correctly titled testbox, the path and executable file are correct, but it does not appear to understand that it should be executing the variable _exeCall. This works properly when executed on the server in commandline, but not from SQL Server's commandline tool.

Execute sql in a file via sqlcmd

I have some insert statements in a .sql file.
I want to execute the insert statements via sqlcmd and tried to do it like this:
sqlcmd -S (localdb)\MSSQLLocalDB -i C:\BacklogItems\15298\dbo.ak_funktion_typ.Table.sql
Unfortunately, I get the following error:
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'S'.
What could be the problem with the -S?
According to https://www.mssqltips.com/sqlservertip/4924/execute-sql-server-script-files-with-the-sqlcmd-utility/ the I can provide the server name via this parameter...
I've made sure that the query is in the SQLCMD Mode.
Thanks in advance for any tips
The reason you are getting that error is because you need to execute sqlcmd in a Windows Command Prompt environment, not in a SQL editor environment such as SSMS. sqlcmd is a separate executable (.exe) utility which has some equivalence to a GUI such as SSMS, in that it is another type of client program for communicating with the database server. It is not a tool which is used within SSMS itself (or any other SQL client).

The file specified for :r command was not found

In MS SQL Server Management Studio in SQLCMD Mode I use this script to run another script:
:setvar path "C:\workspace\scripts\scripts\"
:r $(path)'VERSIONS.sql'
But it gets this error:
A fatal scripting error occurred. The file specified for :r command
was not found.
VERSIONS.SQL is definitely in the specified folder. Why is this script not working when I run it?
EDIT: Something to note. The database I'm running this script against is not on my local machine. (I hope that's not the reason this isn't working)
I just solved my own problem. I changed the single quotes around VERSIONS.sql to double quotes and it worked.
Why are they not interchangeable?

error to get backup sql azure from powershell

I need create and download backup sql database. I installed Azure powershell. But my script does not work.
$dt = Get-Date -Format yyyyMMddHHmmss
$dbname = 'AnimalTranslate'
Backup-SqlDatabase $dbname "C:\drops" "XXX.database.windows.net" "login" "password"
I see error:
Backup-Database : The term 'Backup-Database' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
How it's fixed?
You can't use Backup-SqlDatabase to backup Azure SQL. You need to use one of the methods in this article:
http://msdn.microsoft.com/en-us/library/windowsazure/jj650016.aspx