sqlcmd

SQLCMD :r <path> where path is a variable

不羁岁月 提交于 2019-12-23 09:33:50
问题 Does the SQLCMD command :r support non-constant literal paths? For example: setvar $(path1) '.\script.sql' :r $(path1) -- SQL01260: A fatal parser error occurred: . :r '$(path1)' -- SQL01260: A fatal parser error occurred: . :r "$(path1)" -- SQL01260: A fatal parser error occurred: . 回答1: Does the SQLCMD command :r support non-constant literal paths? It does. You are defining your variable in a wrong way. Try: :setvar path1 "script.sql" :r $(path1) See also this article on MSDN. 回答2: Just

Sqlcmd command without username and password in SQL Server 2008?

浪尽此生 提交于 2019-12-23 07:27:27
问题 How can I run commands, passed to sqlcmd , as currently logged on user automatically i.e without having to enter username and password? I want to use Windows Authentication only. It is a local server. Thanks, 回答1: sqlcmd takes the -E argument, which means, "Use Trusted Connection"... IOW, your windows credentials. http://msdn.microsoft.com/en-us/library/ms162773.aspx 来源: https://stackoverflow.com/questions/15701829/sqlcmd-command-without-username-and-password-in-sql-server-2008

Sqlcmd command without username and password in SQL Server 2008?

泄露秘密 提交于 2019-12-23 07:27:16
问题 How can I run commands, passed to sqlcmd , as currently logged on user automatically i.e without having to enter username and password? I want to use Windows Authentication only. It is a local server. Thanks, 回答1: sqlcmd takes the -E argument, which means, "Use Trusted Connection"... IOW, your windows credentials. http://msdn.microsoft.com/en-us/library/ms162773.aspx 来源: https://stackoverflow.com/questions/15701829/sqlcmd-command-without-username-and-password-in-sql-server-2008

How can I run sqlcmd.exe from an ASP page?

偶尔善良 提交于 2019-12-22 08:06:22
问题 As part of our database revision control (and auto-installation) procedures we need to be able run sqlcmd.exe on various .sql files from within an ASP page. The code I'm using to do this is: Dim cmd : cmd = "sqlcmd -S " & DATABASE_SERVER & " -U " & DATABASE_UID & " -P " & DATABASE_PWD & " -d " & DATABASE_NAME & " -i """ & scriptPath & """ -b" Dim wshShell : Set wshShell = Server.CreateObject("WScript.Shell") Dim return : return = wshShell.Run(cmd, 0, True) I have the code working on my

sql scripting variable default value

房东的猫 提交于 2019-12-22 04:37:12
问题 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. When I call test.sql from caller.sql I can set the scripting variable and all is well. However, I want to use a default value for the scripting value so that if the caller does not set the variable, or if I run test.sql directly (not from caller.sql) then the scripting variable defaults to a set

Exporting CSV data using SQLCMD.EXE

痴心易碎 提交于 2019-12-22 03:32:34
问题 I'm trying to export data from SQL Server into CSV format. I have a bat task to do this that's run at regular intervals. Command is: SQLCMD.EXE -d [db details] -i c:\export.sql -o c:\export.csv -s"," -W The SQL file is just a SELECT * from a view. This works except that some of the rows have commas in the data, so the values need to be quoted. I could change the column separator to be "','", but then I'd need SQL Server to escape single quotes in the data as well. Unfortunately changing the

Exporting CSV data using SQLCMD.EXE

大城市里の小女人 提交于 2019-12-22 03:31:05
问题 I'm trying to export data from SQL Server into CSV format. I have a bat task to do this that's run at regular intervals. Command is: SQLCMD.EXE -d [db details] -i c:\export.sql -o c:\export.csv -s"," -W The SQL file is just a SELECT * from a view. This works except that some of the rows have commas in the data, so the values need to be quoted. I could change the column separator to be "','", but then I'd need SQL Server to escape single quotes in the data as well. Unfortunately changing the

How to properly manage database deployment with SSDT and Visual Studio 2012 Database Projects?

谁都会走 提交于 2019-12-20 07:58:21
问题 I'm in the research phase trying to adopt 2012 Database Projects on an existing small project. I'm a C# developer, not a DBA, so I'm not particularly fluent with best practices. I've been searching google and stackoverflow for a few hours now but I still don't know how to handle some key deployment scenarios properly. 1) Over the course of several development cycles, how do I manage multiple versions of my database? If I have a client on v3 of my database and I want to upgrade them to v8, how

cmd.ExecuteNonQuery value of i integer is going -1 from 0

被刻印的时光 ゝ 提交于 2019-12-19 08:18:06
问题 Here i create table in database dynamically. User enters name as his wish and selects language radiobutton. So problem is after executing cmd.ExecuteNonQuery value of i integer is going -1 from 0. And shows that table couldnt be created but when i go to database its already created successfully. Please let me know where i am doing wrong. Thanx in Advance !! protected void btnpaper_Click(object sender, EventArgs e) { try { string conn = ConfigurationManager.ConnectionStrings["sqlconn"]

cmd.ExecuteNonQuery value of i integer is going -1 from 0

六月ゝ 毕业季﹏ 提交于 2019-12-19 08:18:02
问题 Here i create table in database dynamically. User enters name as his wish and selects language radiobutton. So problem is after executing cmd.ExecuteNonQuery value of i integer is going -1 from 0. And shows that table couldnt be created but when i go to database its already created successfully. Please let me know where i am doing wrong. Thanx in Advance !! protected void btnpaper_Click(object sender, EventArgs e) { try { string conn = ConfigurationManager.ConnectionStrings["sqlconn"]