sqlcmd Questions

4

Solved

I'm running the Microsoft SQLCMD tool for Linux (CTP 11.0.1720.0) on a Linux box (Red Hat Enterprise Server 5.3 tikanga) with Korn shell. The tool is properly configured, and works in all cases exc...
Alika asked 26/7, 2012 at 11:21

4

Solved

This works but not in utf-8: sqlcmd -S Server -d DB -E -s, -W -i "C:\Localdata\test.sql" | findstr /V /C:"-" /B > "C:\Localdata\Test.csv" Would anybody like to help fix this into utf-8?
Undistinguished asked 10/1, 2017 at 5:22

3

Solved

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... ho...
Immaterial asked 15/10, 2015 at 16:48

1

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 r...
Lengthen asked 15/8, 2019 at 7:45

2

Solved

I want to spool my output to a particular file. My database in SqlServer. I am entering code in command prompt like this: First I am connecting to my data base like this: sqlcmd -S SUPPORT2/SUPPO...
Amphioxus asked 1/9, 2013 at 7:3

2

Solved

FOR /f "delims=" %%a IN ('"%SQLCMD%" -E -S %Server% -d %DestDb% -h-1 -i GetResult.sql') do ( SET Result=%%a ) ECHO "%Result%" %Result% is set to the first 256 characters of the actual result. I...
Pendley asked 27/7, 2017 at 12:40

5

Solved

I have a .sql script and I want to build a database from it. How to do it in sqlcmd? I know it's like: CREATE DATABASE dbName GO But how to specify the .sql script and location to build the data...
Hardner asked 1/1, 2012 at 14:27

4

Solved

I am using powershell and using Invoke-SqlCmd. I am able to pass variables to SQL: $variables = @( "MyVariable='hello'" ) Invoke-SqlCmd ` -ServerInstance 'localhost' ` -Database 'master' ` -Us...
Salangia asked 2/2, 2016 at 15:12

3

I am using below command line to run a SQL query using SQLCMD sqlcmd -S Server -Q "select top 100 * From people" -d people -t 10 The table has 20 columns and when i look at output command line ...
Dismast asked 16/11, 2015 at 15:4

3

Solved

I'm on Ubuntu 16.04 trying to use sqlcmd launched programmatically from a script to do a SQL query in the VM's cloud. vm-dev:~$ sudo sqlcmd -S my-db.url.net -d my-db I keep getting this error: ...
Deduct asked 27/3, 2018 at 16:25

3

Solved

I'm porting our deployment infrastructure to Azure DevOps (formerly Visual Studio Team Services), but I've run into an issue I can't find any good solutions to. We're using EF Core Migrations, and...
Eboh asked 15/10, 2018 at 18:2

2

The following command in a cmd window sqlcmd -S. -Usa -Ppass -dmaster -Q "RESTORE DATABASE [MYDATABASE] FROM DISK = 'D:\SQL Server\MYDATABASE.BAK' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 10&...

6

I have a script file e.g. test.sql. I want to call this from another script, say caller.sql, in sqlcmd mode using :r test.sql. This works fine, but I want to use a scripting variable in test.sql. W...
Giff asked 19/9, 2010 at 18:50

2

I am using SQLCMD mode. I want to set setvar variable value. How should I set value in :setvar? My Code are look like this : DECLARE @DatabaseName AS nvarchar(180) set @DatabaseName = '$(dbName)' ...
Apoplexy asked 5/11, 2018 at 9:7

1

Solved

I am running a moderately large script (about 900MB) with SQLCMD.exe and I am running into an odd situation. The script consists of several thousand insert statements. When I run it, it will run f...
Deimos asked 30/10, 2018 at 18:35

8

Solved

Is there any possibility to encrypt all existing stored procedures of a SQL Server 2008 database AFTER they have been created via an SQLCMD script? The reason I want to do this is the following: I...

3

I am trying to create my own Docker image with MSSQL DB for development. It's based on microsoft/mssql-server-linux image. During the build I want to copy some .sql files into the container and the...
Osteoarthritis asked 23/10, 2017 at 11:16

1

Solved

so this is the query that i want to run sqlcmd -E -S localhost\MSSQLSERVER_2016 -i C:\Tables.sql I have multiple databases in this instance and when the command above runs, i have no idea which...
Sawicki asked 19/7, 2018 at 15:25

2

Solved

In PowerShell I'm using Microsoft.SqlServer.Dac.DacServices and Microsoft.SqlServer.Dac.DacDeployOptions to deploy/update a database DACPAC. The problem I am having is finding where to set the SQLC...
Rapallo asked 18/2, 2015 at 16:42

6

Is there a way to run a query and then have SQL Server management studio or sqlcmd or something simply display the datatype and size of each column as it was received. Seems like this information ...
Lumbar asked 22/6, 2009 at 19:21

3

I am currently learning SQL Server and am having problems connecting to my local database using sqlcmd. When I type in the following into Powershell: sqlcmd -S "(localdb)\mssqllocaldb" I get th...
Julijulia asked 24/7, 2016 at 7:22

2

Solved

In SQL Server 2008, I want to export the result of a stored procedure to a file using sqlcmd utility. Now the end of my stored procedure is a select statement with a "for xml path.." clause at the ...
Fatness asked 28/3, 2010 at 16:15

3

Solved

I am trying to run a SQL script locally using sqlcmd, but I keep getting the following response: HResult 0xFFFFFFFF, Level 16, State 1 SQL Server Network Interfaces: Error Locating Server/Insta...
Mendymene asked 18/5, 2014 at 12:7

2

Working with debian linux inside a docker contaier. I have sqlcmd working properly and the neseccary drivers are installed and locatable. I know the server exists: root@0feafecac36f:/home/shiny# n...
Sheritasherj asked 25/1, 2018 at 20:52

2

I am having an issue running SQL scripts generated by the Publish > Generate Scripts dialog on a SQL Server Database Project (Visual Studio 2013). The generated script executes fine and usually wi...
Wither asked 27/1, 2015 at 0:7

© 2022 - 2025 — McMap. All rights reserved.