sqlcmd

How to get SQLCMD to output errors and warnings only

狂风中的少年 提交于 2019-12-09 09:30:28
问题 How can you get SQLCMD, when executing a SQL script file, to just output any errors or warnings it encounters? I essentially dont want information based messages to be output. 回答1: It's not possible to prevent SQLCMD returning non-error output messages by passing it a parameter. However, what you can do is redirect error messages to STDERR , then direct all other messages to NUL . This is done by passing the -r parameter. From books online: -r[ 0 | 1] msgs to stderr Redirects the error

How not to include sql file content when publishing?

﹥>﹥吖頭↗ 提交于 2019-12-09 06:43:29
I have a question that is very similar to an older question of mine Using variable in sql postdeployment build script? But now I don´t want to do an if/else and have the sql code in my published script. I don´t want to share information beetween customers. So... here goes I have a database project in Visual Studio. I also have 2 customers with different needs I know I can use post.deployment script to include content of sql files I need by setting a varible in Project.Properties."SQLCMD Variables". And then use it like this in Script.PostDeployment.sql :r ..\$(Customer)Setup.sql Where I have 2

Can I print immediately for each iteration in a loop?

亡梦爱人 提交于 2019-12-09 00:18:08
问题 My deployment server runs a deployment script for every new database build. Part of the script blocks to wait for another asynchronous operation to complete. The blocking code looks like this: DECLARE @i INT = 0; DECLARE @laststatus NVARCHAR(MAX) = N''; WHILE @i < 5 BEGIN -- the real delay is longer WAITFOR DELAY '00:00:01'; -- poll async operation status here SET @i = @i + 1; SET @laststatus = N'status is ' + CAST(@i AS NVARCHAR(MAX)); RAISERROR(@laststatus, 0, 1) WITH NOWAIT; END; It uses

trying to run sqlcmd fails, unable to establish connection?

折月煮酒 提交于 2019-12-08 17:19:16
问题 When I try to run sqlcmd (from the cmd prompt) I get the following error: HResult 0x2, Level 16, State 1 Named Pipes Provider: Could not open a connection to SQL Server [2]. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in stance-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 i f SQL Server is configured to allow remote connections. For more information see

sqlcmd script with spaces in filename

爷,独闯天下 提交于 2019-12-08 15:44:47
问题 I have a simple SQLCMD script that includes some lines like this: /* Load data into Exampletable */ BULK INSERT dbo.Example /* NOTE: I've tried single AND double quotes here. */ FROM "C:\Example Filepath\test.csv" WITH ( /* skip the first row containing column names */ FIRSTROW = 2, /* specify how fields are separated */ FIELDTERMINATOR = '|', /* specify how lines end */ ROWTERMINATOR = '\n' ) When I run it on the command line, I get an error like this: Sqlcmd: 'C:\Example': Invalid filename.

How to run sqlcmd remotely on a machine which does not have SSMS

假装没事ソ 提交于 2019-12-08 09:54:32
问题 Is there a way in which we can run sqlcmd on a machine without having SSMS. 回答1: If you follow this link for Microsoft SQL Server 2008 R2 Feature Pack , you should be able to download it for the machine without needing to install SQL server. Also, see this link for Microsoft Command Line Utilities 11 for SQL Server which might be better. 来源: https://stackoverflow.com/questions/18872387/how-to-run-sqlcmd-remotely-on-a-machine-which-does-not-have-ssms

Which user account is running SQLCMD in T-SQL Script without -U and -P option?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 06:38:20
问题 I am using sqlcmd in a T-SQl script to write a text file to a network location. However SQLCMD is failing to write to that location due to access permission to the network folder. SP is being run under my user account which has access to the network folder. Could you please help me under which account sqlcmd will run if I do not specify -U and -P option in TSQL Script? 回答1: Use this to find the user name: PRINT Suser_Sname(); 回答2: If you don't provide credentials with -u/-p it will try to use

How not to include sql file content when publishing?

匆匆过客 提交于 2019-12-08 05:57:12
问题 I have a question that is very similar to an older question of mine Using variable in sql postdeployment build script? But now I don´t want to do an if/else and have the sql code in my published script. I don´t want to share information beetween customers. So... here goes I have a database project in Visual Studio. I also have 2 customers with different needs I know I can use post.deployment script to include content of sql files I need by setting a varible in Project.Properties."SQLCMD

SQL Script Command Line Arguments

对着背影说爱祢 提交于 2019-12-08 04:18:30
问题 Is there a way to get a script file that will be executing via SQLCMD to accept the parms passed in the SQLCMD call.. ie.. SQLCMD (assume the connection is OK..) -V "1/25/2012" -i "ScriptFile.sql" What would the structure of ScriptFile.sql Look like? Would it start with the same as any other procedure..? Basically I'm trying to call a text file script with parameters as an SQL command. So far I haven't been able to find any MSDN articles on this one. 回答1: OK.. If anyone cares, it Goes Like

Remote Informix 11.5 Command Line Client

我只是一个虾纸丫 提交于 2019-12-07 22:51:26
问题 Does a command line tool ship with Informix 11.5 similar to SQLCMD for SQL Server? If yes, how do I connect to a remote server and perform regular SELECT/INSERT/UPDATE queries using it? 回答1: As Michal Niklas says, the standard tool provided with IBM Informix Dynamic Server (colloquially IDS or even just Informix) is DB-Access. However, it is distributed only with IDS itself, not with the Informix Client SDK (CSDK) or Informix Connect (I-Connect) products. If you want to access IDS from a