Tag Info

Hot answers tagged

8

I think you might want the "SET NOCOUNT ON" option. Your SQL script will look like: set nocount on select x, y, z from agent set nocount off And the results set will be: 24 aingles1 creablegs 25 tbails12 bull2dog12 26 jtaylor3 Leandon62606 27 forrestw1 nuke19211 Minus ...


6

SQL is the command interpreter here, not the shell, so escaping with another \ will not work. You have to surround the login with brackets. ALTER LOGIN [DOMAIN\Username] WITH DEFAULT_DATABASE = AvailDBName


4

Try this: sqlcmd -S .\SQLEXPRESS -q "drop database [aspnet-ORData-20120910180110]" Note the square brackets around the database name. Without them the dashes ("-") are seen as tokens instead of part of the database name and the parser will want to do math. The command parser interprets anything inside square brackets as a literal.


2

sqlcmd -S svr -d db ... | findstr /v "rows affected" findstr is built into the OS and is simliar to grep. See findstr /? for more options. To remove a column: Use cut.exe from http://unxutils.sourceforge.net/ The you could run: sqlcmd -S svr -d db ... | cut -c10- This would only output from character 10 onwards, thus removing the line numbers. Adjust ...


2

Don't know if someone still needs this but I did. So I tried and it's pretty straight forward. sqlcmd -h -1 -s "," -W [...] Where : -h -1 gets rid of header -s "," set the comma as column separator -W is needed to remove trailing space [...] is the remaining of your sqlcmd


1

I finally seem to have resolved the problem by changing the start time of the scheduled task from 1AM to 2AM. Something else must be heavily loading the system at 1AM so that the connection is really timing out.


1

Follow this guide . You need to create a SQL script that backup the database specified in it on the desired location, then you can call that sql script from SQLCMD . For example if you call the backup script backup.sql : sqlcmd -S .\SQLEXPRESS -i backup.sql -o output.txt Example of backup.sql : DECLARE @Path NVARCHAR(1000), @FileName NVARCHAR(255), ...


1

When you come across the problem again, click on the upperleft of the sqlcmd window (to the left of the window's title). From the drop-down, choose Defaults and click Insert Mode. Do the same for Properties (also from the drop-down box). You might want to also enable Quick Edit mode. With Quick Edit mode, you can hightlight text and then hit enter to ...


1

I had similar problems working with SQLCMD in Bash and as of now this question is ranked third when searching for sqlcmd cygwin on Google. I too thought that it was due to line endings because of the error, Sqlcmd: Error: Internal error at ReadTextLine (Reason: Unspecified error). I tried various trickery such as process substitution but that didn't work. ...


1

I think the problem is with SQL Server's script generator, see this bug report for more info.


1

You can't. You would need to create a table and do an INSERT INTO #MyTable RESTORE HEADERONLY ... Then select only the columns that you want from the table.


1

This is standard practice. You wouldn't want your users trying to submit changes to a database that is being backed up. Also, stop doing backups during production hours. Schedule them for after-hours or something. It's very poor practice to do otherwise.


1

Change remove one of the slashes in SET SERVER=.\\sqlexpress. It should be SET SERVER=.\sqlexpress


1

you tried escaping it with another \ ? would be DOMAIN\\user


1

In addition to the SQL Server 2008 Command Line Utiltiies, you can also install the SQL Server client components. This will install SSMS and BIDS, too, though. As far as the SQL Native Client, consider it similar to the driver which permits a connection to a SQL Server using the most recent options for that version. You'll still need client tools, and ...



Only top voted, non community-wiki answers of a minimum length are eligible