sqlcmd

Run sqlcmd without having SQL Server installed

拜拜、爱过 提交于 2019-11-28 22:17:29
问题 I'm working on a Java program that is calling sqlcmd . It works perfectly on a computer with SQL server installed, but not at all on a computer that doesn't. I want to include the necessary exe and dll files to run this command in my jar. Anyone know which ones I need? I already included batchparser90.dll, sqlcmd.exe, and sqlcmd.dll. It still didn't work. Any suggestions are appreciated. Thanks in advance! 回答1: Although it's probably too late for the original poster, for future reference,

How to pass in parameters to a SQL Server script called with sqlcmd?

时光毁灭记忆、已成空白 提交于 2019-11-28 08:58:31
Is it possible to pass parameters to a SQL Server script? I have a script that creates a database. It is called from a batch file using sqlcmd. Part of that SQL script is as follows: CREATE DATABASE [SAMPLE] ON PRIMARY ( NAME = N'SAMPLE', FILENAME = N'c:\dev\SAMPLE.mdf' , SIZE = 23552KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'SAMPLE_log', FILENAME = N'c:\dev\SAMPLE_log.ldf' , SIZE = 29504KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) I want to be able to pass in the filenames for the database and the log so that I don't have to hardcode 'C:\dev\SAMPLE.mdf' and 'C:\dev\SAMPLE

Is there a way to suppress “x rows affected” in SQLCMD from the command line?

我的未来我决定 提交于 2019-11-28 07:07:13
Is there a way to suppress "x rows affected" in SQLCMD from the command line? I'm running an MSBuild script and don't want it clogging up my log on my build server. I'd rather not have to add "SET NOCOUNT ON" in every script, so if there's a way to do it from the command line, that would be fantastic. What about creating a startup script with SET NOCOUNT ON in the script (assign the script to the SQLCMDINI environment variable). http://msdn.microsoft.com/en-us/library/ms162773.aspx Cade Roux The -i and -q options are mutually exclusive . Create a file named setnocount.sql with the content: SET

SQL Server Network Interfaces: Connection string is not valid [87]

风流意气都作罢 提交于 2019-11-28 04:06:17
问题 When I am running this from cmd on my SQL Server 2008 instance: sqlcmd -U sa -S mymachinen_name\MSSQLSERVER (where MSSQLSERVER is my instance name) I get prompt for password and after that I get this: Password: HResult 0x57, Level 16, State 1 SQL Server Network Interfaces: Connection string is not valid [87]. Sqlcmd: Error: Microsoft SQL Server 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

SET QUOTED IDENTIFIER should be ON when inserting a record

回眸只為那壹抹淺笑 提交于 2019-11-27 23:56:13
I am stuck in a rather strange problem with SQL Server 2005, which throws "SET QUOTED IDENTIFIER should be on when inserting record" (using as SP) to the particular table. This worked fine earlier but is throwing this error randomly. I have verified the SP. We didn't manually specify SET QUOTED IDENTIFIER settings inside, so it must be ON by default. Can someone clarify what could be the problem? The table must be created with SET QUOTED IDENTIFIER ON right? I didn't check the table script yet. I have observed that this problem only occur with the SPs doing insert or update on a date column

How to export SQL Server 2005 query to CSV

◇◆丶佛笑我妖孽 提交于 2019-11-27 17:47:37
I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right way. I've looked at bcp, but I can't figure out how to put the quotes around the fields (except concatenating them to the field values, which is ugly). I guess I could do it with sqlcmd and -o, but that seems ugly for the same reason. Is there a bcp way to do it? Is there a reasonable sqlcmd way to do it? Is there some great, simple utility built into the Management Studio that I'm just overlooking? In Management Studio, select

How do I grant myself admin access to a local SQL Server instance?

旧巷老猫 提交于 2019-11-27 16:59:05
I installed SQL Server 2008 R2 to my local machine. But, I can't create a new database because of rights (or lack of). "CREATE DATABASE PERMISSION DENIED" So, I tried to assign the admin privileges to my current login "User does not have permission to perform this action." I also tried to create a new login that would have admin privileges but with no luck. How do I grant myself admin rights so that I can create a database? I can re-install, but I prefer not to. Brian Knight Yes - it appears you forgot to add yourself to the sysadmin role when installing SQL Server. If you are a local

Is there a way to suppress “x rows affected” in SQLCMD from the command line?

有些话、适合烂在心里 提交于 2019-11-27 01:43:24
问题 Is there a way to suppress "x rows affected" in SQLCMD from the command line? I'm running an MSBuild script and don't want it clogging up my log on my build server. I'd rather not have to add "SET NOCOUNT ON" in every script, so if there's a way to do it from the command line, that would be fantastic. 回答1: What about creating a startup script with SET NOCOUNT ON in the script (assign the script to the SQLCMDINI environment variable). http://msdn.microsoft.com/en-us/library/ms162773.aspx 回答2:

How do I grant myself admin access to a local SQL Server instance?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 22:30:41
问题 I installed SQL Server 2008 R2 to my local machine. But, I can't create a new database because of rights (or lack of). "CREATE DATABASE PERMISSION DENIED" So, I tried to assign the admin privileges to my current login "User does not have permission to perform this action." I also tried to create a new login that would have admin privileges but with no luck. How do I grant myself admin rights so that I can create a database? I can re-install, but I prefer not to. 回答1: Yes - it appears you

SET QUOTED IDENTIFIER should be ON when inserting a record

℡╲_俬逩灬. 提交于 2019-11-26 21:36:18
问题 I am stuck in a rather strange problem with SQL Server 2005, which throws "SET QUOTED IDENTIFIER should be on when inserting record" (using as SP) to the particular table. This worked fine earlier but is throwing this error randomly. I have verified the SP. We didn't manually specify SET QUOTED IDENTIFIER settings inside, so it must be ON by default. Can someone clarify what could be the problem? The table must be created with SET QUOTED IDENTIFIER ON right? I didn't check the table script