sqlcmd

“Login timeout expired” error when accessing MS SQL db via sqlalchemy and pyodbc

末鹿安然 提交于 2020-08-27 03:59:19
问题 So I have some trouble getting sqlalchemy and pyodbc working with a remote MS SQL Server. Local sqlcmd worked properly but not when I try to read the db via python code. Any help would be appreciated. Environment: Centos 7 SQLCmd version: Version 17.1.0000.1 Linux MS SQL Server 6.01.7601.17514 Python 2.7 The following sqlcmd worked properly sqlcmd -S {Host},{Port} -U {USER} -P {PWD} -Q "use {Database};" Attempts to work with sqlalchemy or pyodbc directly didn't work. Error: pyodbc

sqlcmd in bash file - store to variable

为君一笑 提交于 2020-08-26 12:52:58
问题 Running in a docker container, I am trying to determine if a table exits in the mssql database: RESULT='/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i "SELECT name FROM master.sys.databases WHERE name = N'MyTable'"' if [ "$RESULT" == "MyTable" ]; then echo YES fi echo "$RESULT" echo "$RESULT" always just outputs the entire command as a string, its not getting executed. So its just assigning it as a sting... How can I execute it and assign the result? 回答1: Bash

sqlcmd in bash file - store to variable

耗尽温柔 提交于 2020-08-26 12:49:15
问题 Running in a docker container, I am trying to determine if a table exits in the mssql database: RESULT='/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i "SELECT name FROM master.sys.databases WHERE name = N'MyTable'"' if [ "$RESULT" == "MyTable" ]; then echo YES fi echo "$RESULT" echo "$RESULT" always just outputs the entire command as a string, its not getting executed. So its just assigning it as a sting... How can I execute it and assign the result? 回答1: Bash

Drop DB but don't delete *.mdf / *.ldf

一个人想着一个人 提交于 2020-07-22 05:06:39
问题 I am trying to automate a process of detaching and dropping a database (via a VBS objshell.run) If I manually use SSMS to detach and drop I can then copy to database files to another location... however if I use: sqlcmd -U sa -P MyPassword -S (local) -Q "ALTER DATABASE MyDB set single_user With rollback IMMEDIATE" then sqlcmd -U sa -P MyPassword -S (local) -Q "DROP DATABASE MyDB" It detaches/drops and then deletes the files. How do I get the detach and drop without the delete? 回答1: The MSDN

Drop DB but don't delete *.mdf / *.ldf

让人想犯罪 __ 提交于 2020-07-22 05:06:04
问题 I am trying to automate a process of detaching and dropping a database (via a VBS objshell.run) If I manually use SSMS to detach and drop I can then copy to database files to another location... however if I use: sqlcmd -U sa -P MyPassword -S (local) -Q "ALTER DATABASE MyDB set single_user With rollback IMMEDIATE" then sqlcmd -U sa -P MyPassword -S (local) -Q "DROP DATABASE MyDB" It detaches/drops and then deletes the files. How do I get the detach and drop without the delete? 回答1: The MSDN

Facing errors while SQL deployment in azure devops pipeline

点点圈 提交于 2020-06-01 06:07:25
问题 Am using sql DACPAC type of deployment in release pipeline of azure devops.but getting below error. I have no idea about SQL.Any suggestions? Publishing to database 'database_name' on server 'Server_name'. Initializing deployment (Start) *** The column [dbo].[xxxx].[yyyy] is being dropped, data loss could occur. Initializing deployment (Complete) Analyzing deployment plan (Start) *** If this deployment is executed, changes to [dbo].[xxx2] might introduce run-time errors in [dbo].[yyyy2].

Unable to reach SQL database through SSH tunnel using sqlcmd

帅比萌擦擦* 提交于 2020-04-10 14:09:47
问题 I need to connect to a an Azure SQL DB from my local machine through a jump box (Azure VM). I set up the port forwarding using the command: ssh -fN -L 41433:my-db.database.windows.net:1433 me@jump-box I can confirm the tunnel is set up because in verbose mode i see the message Local connections to LOCALHOST:41433 forwarded to remote address my-db.database.windows.net:1433 Now, when I run sqlcmd -S 127.0.0.1,41433 -U username -P password -d db I get the following error message Sqlcmd: Error: