sqlcmd

How do I INSERT binary data from a local file with SQLCMD?

爷,独闯天下 提交于 2021-02-10 16:01:23
问题 I need to insert binary data from a file into a varbinary(max) column in SQL Server as a part of my deployment script. The file is on the local machine, SQL Server is on the remote. Here is the data table definition CREATE TABLE [dbo].[Config] ( [ID] INT IDENTITY (1, 1) NOT NULL, [Name] NVARCHAR (50) NOT NULL, [Cfg] VARBINARY(MAX) NOT NULL ); I need something like this pseudo-command INSERT INTO Config(ID, Name, Cfg) VALUES (0, 'Default', ????('Default.cfg')??? ) i.e. data is taken from a

Unicode support for Invoke-Sqlcmd in PowerShell

别等时光非礼了梦想. 提交于 2021-02-07 11:58:37
问题 The PowerShell sqlps module provides core support for SQL Server access from within PowerShell and its Invoke-Sqlcmd cmdlet is its main workhorse for executing literal queries or SQL script files (analogous to the non-PowerShell sqlcmd utility). I recently tried some experiments to confirm that Invoke-Sqlcmd handles Unicode and had some surprising results. I started with this simple script file (named unicode.sql): CREATE TABLE #customers ( [IdCust] int, [FirstName] nvarchar(25), [SurName]

Error Handling with Batch File & Sqlcmd

痞子三分冷 提交于 2021-02-06 09:56:50
问题 I have a batch file that runs some SELECT queries using sqlcmd, puts the results into text files, and uploads those files onto an FTP server. That's all working just the way it should, which is how I like things to work. I've been wondering about what I would do in the event of an error, though. Let's say someone changes the data structure of the database I'm hitting and doesn't notify me. If I ran a sqlcmd SELECT statement and dropped the result into a text file, I would just end up with a

SQL Server 2008 R2 - sqlcmd bat file to run a batch of sql queries in folder but they are not running in order of file name

人盡茶涼 提交于 2021-01-27 20:16:32
问题 I have a bunch of written sql scripts that I have written and I was looking to run as a batch in order in a folder. After reading up I've resorted to creating a bat file which includes using the sqlcmd. For this particular set of scripts, when i run the bat it doesn't seem to run in order. I have no idea what is going on as I've tried renaming the sql scripts numerically with a prefix number in the beginning, tried using letters, and even renaming the whole script to just a number/letter

sqlcmd - How to get around column length limit without empty spaces?

梦想与她 提交于 2021-01-27 04:10:01
问题 I'm trying to use sqlcmd on a windows machine running SQL Server 2005 to write a query to a csv file. The command line options we typically use are: -l 60 -t 300 -r 1 -b -W -h -1 However, the columns are getting truncated at 256 bytes. In an attempt to circumvent this, I tried using this command line option in place of -W: -y 8000 This captures the entire fields, but the problem with this method is that the file balloons up from just over 1mb to about 200mb due to all the extra space (I

sqlcmd - How to get around column length limit without empty spaces?

馋奶兔 提交于 2021-01-27 04:09:06
问题 I'm trying to use sqlcmd on a windows machine running SQL Server 2005 to write a query to a csv file. The command line options we typically use are: -l 60 -t 300 -r 1 -b -W -h -1 However, the columns are getting truncated at 256 bytes. In an attempt to circumvent this, I tried using this command line option in place of -W: -y 8000 This captures the entire fields, but the problem with this method is that the file balloons up from just over 1mb to about 200mb due to all the extra space (I

sqlcmd - How to get around column length limit without empty spaces?

只愿长相守 提交于 2021-01-27 04:08:10
问题 I'm trying to use sqlcmd on a windows machine running SQL Server 2005 to write a query to a csv file. The command line options we typically use are: -l 60 -t 300 -r 1 -b -W -h -1 However, the columns are getting truncated at 256 bytes. In an attempt to circumvent this, I tried using this command line option in place of -W: -y 8000 This captures the entire fields, but the problem with this method is that the file balloons up from just over 1mb to about 200mb due to all the extra space (I

SSDT Publish errors on Creating Publish Preview

我的梦境 提交于 2021-01-20 16:33:28
问题 I am using Visual Studio 2013 to manage a .sqlproj file containing our database schema. The schema has been deployed successfully dozens of times. When attempting to publish to one specific target database, the "Creating publish preview" step appears to fail, but no error is given. The output from the preview includes some expected warnings: The column {...} is being dropped, data loss could occur If this deployment is executed, changes to {...} might introduce run-time errors in {...} This

sqlcmd.exe - Shared Memory Provider: No process is on the other end of the pipe

≡放荡痞女 提交于 2021-01-03 06:35:43
问题 I have read numerous posts and articles about the error: Shared Memory Provider: No process is on the other end of the pipe. Communication link failure. ...including these: Error message: (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ I can connect easily and always from SSMS, both

sqlcmd.exe - Shared Memory Provider: No process is on the other end of the pipe

旧巷老猫 提交于 2021-01-03 06:35:05
问题 I have read numerous posts and articles about the error: Shared Memory Provider: No process is on the other end of the pipe. Communication link failure. ...including these: Error message: (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) https://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/ I can connect easily and always from SSMS, both