sqlcmd

Microsoft SQL Server Native Client 10.0 Login timeout expired

浪尽此生 提交于 2019-12-19 08:06:54
问题 I have a freshly installed SQL Server 2008 R2 Express. I'm trying to run SQLCMD locally (please do take note locally ) but I am receiving the error: Named Pipes Provider: Could not open a connection to SQL Server [2] Sqlcmd: Error: Microsoft SQL Serve Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow

Need help to write bat file that execute sql scripts in (sql server 2008 and another 3 files.?

僤鯓⒐⒋嵵緔 提交于 2019-12-19 02:06:42
问题 I am sure these has been asked before but cannot find clear instruction how to create a batch file lets call it "Update Database" this batch file should Execute sql scripts located in different folders Execute another 3 bat files. Any quick examples how to do it?Never done it before thanks a lot EDITED Can I do this? :On Error exit :r C:\myPath\MasterUpdateDatabase.bat GO SQLCMD -S (Local) -i C:\myPath\InsertUsername.sql I get an error: "GO" is not recognized as internal external command

Installing sqlcmd in silent mode accepting EULA

天涯浪子 提交于 2019-12-14 03:26:34
问题 I'm trying to install sqlcmd in silent mode but i can't figure out how to automatically accept the EULA. The file I'm trying to install is named "MsSqlCmdLnUtils.msi" (downloaded from the MS download center). Here's what I've tried till now (found with google): msiexec /i "MsSqlCmdLnUtils.msi" /passive AcceptEndUserLicenseAgreement=1 msiexec /i "MsSqlCmdLnUtils.msi" /passive ACCEPTEULA=1 msiexec /i "MsSqlCmdLnUtils.msi" /passive ACCEPT=1 msiexec /i "MsSqlCmdLnUtils.msi" /passive EULA=1 and

SQLCMD command, How to save output into log file

血红的双手。 提交于 2019-12-13 16:30:50
问题 The following question has helped me solving the problem of executing multiple SQL Scripts located in file. Run all SQL files in a directory However, I did not get how to redirect the output into a separate log file. Someone suggested the following script but since I don't understand it, it did not work and I can't find out the error. for %f in (*.sql) do sqlcmd /S <servername> /d <dbname> /E /i "%f" >> sql.log 2>&1) 回答1: If you need the output into one common file then you should use the

Combine command line and T-SQL - SQL Server

五迷三道 提交于 2019-12-13 13:07:40
问题 I am trying to execute some sqlcmd through T-SQL on SQL Server 2008. There is a part of my code where I am checking a data file size and if that data file size does not equal to 0, then start deleting the specific table so I can BCP in new data. Below is my code that is not being executed: SET @myVariable = ' SETLOCAL FOR %%R IN (X:\Main Folder\Data\'+@databaseName+'_'+@tableName+'.dat) DO SET size=%%~zR IF %size% NEQ 0 ( SQLCMD -E -S my-server-name -Q "DELETE FROM '+@databaseName+'.'+

How can I use SQLCMD with Windows Authentication (-E,) but without elevated permissions

ぐ巨炮叔叔 提交于 2019-12-13 08:36:35
问题 I'm going to create a script to execute numerous SQL files. I've chose to use SQLCMD instead of ADODB because it provides logging information quickly, and we're executing T-SQL. I'm testing out SQLCMD.exe before putting it into the script . Connecting to the database using SQLCMD.exe, I utilize -E for Windows Authentication. This means that I need to use my network account, which does not have elevated access on any given machine. However, SQLCMD.exe requires elevated access in order to

How to bind the -v parameter of sqlcmd from a PowerShell

帅比萌擦擦* 提交于 2019-12-13 06:15:19
问题 The following code, setting the -v parameter directly is working $sqlcmd = @(Resolve-Path "$env:ProgramFiles\Microsoft SQL Server\*\Tools\binn\SQLCMD.EXE")[0] $path1 = 'D:\somescript.sql' & $sqlcmd -b -S NB-BK\SQLEXPRESS -d BK_Prod -U sa -P mypassword -l 180 -i $path1 -v Mandant=1 SAPMandant="009" SAPEinrichtung="0001" But I need a way to set these values from a PowerShell variable. I tried: $sqlcmd = @(Resolve-Path "$env:ProgramFiles\Microsoft SQL Server\*\Tools\binn\SQLCMD.EXE")[0] $path1 =

How can I make a win32 command (sqlcommand) print its output to the console in PowerShell

a 夏天 提交于 2019-12-13 04:51:57
问题 I have a script that eventually calls this line & sqlcmd.exe -S $DbHost -d $DbSchema -Q "do some crazy db change here" Where "do some crazy db change here" will eventually be replaced by a dynamic bit of SQL/script. When I run this whether it succeeds or not I see no output from sqlcmd.exe in my console. For user feedback I'd like to pipe this in real time to the console. How could I do that? 回答1: Here's how I have done it in the past, it makes use of events from StandardOut and StandardError

How to save a SQLCMD code as a executable file

╄→гoц情女王★ 提交于 2019-12-13 04:33:56
问题 I have a set of SQLCMD codes which are to be saved as exe files so that people can just execute the file rather than copy paste the code and run the command in command line. 回答1: Write your sql code to file for example script.sql and than create a batch file (for example run.bat) with below command sqlcmd -U user -P passwrod -S SerwerName -i C:\script.sql 来源: https://stackoverflow.com/questions/18004258/how-to-save-a-sqlcmd-code-as-a-executable-file

How do you reference defined variables in a SQL Server Database Project?

一世执手 提交于 2019-12-13 03:46:47
问题 I've read many questions on this such as: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/da4bdb11-fe42-49db-bb8d-288dd1bb72a2/sqlcmd-vars-in-create-table-script?forum=ssdt and How to run different pre and post SSDT pubish scripts depending on the deploy profile What I'm trying to achieve is a way of defining a set of scripts based on the environment being deployed to. The idea is that the environment is passed in as a SQLCMD variable as part of the azure-devops pipeline into a