osql

Can osql.exe run as a standalone?

Hi, I have a program that runs osql.exe from microsoft sql server tools directory and runs a script. The problem is that on computers that don't have an installation of sql server, this tool is missing. So my question is whether or not is possible to run it as a standalone( along with any dll that may be required ) meaning that run th...

Using osql with nant scripts

I am currently using osql with nant by calling a batch file with arguments. Here are the properties that are defined in my nant script (no, not real username/password values): <property name="project.config" value="debug" /> <property name="server" value="(local)" /> <property name="database" value="Test" /> <property name="username" va...

Running a batch file to update a field with strange character in SQL Server DB

I have a table called Field in my SQL Server database. The table has a field called "Units". I have a batch script which inserts a lot of things into here using OSQL and one of the things entered is the pound sign (£). When OSQL runs the queries, it converts the £ sign to -ú instead. What I need to have is a separate batch file which ...

Help on getting started with powershell - rewrite an old BAT + SQL file

Hi, I'm totally new to powershell, and I need some help to get started. What I need is to write a small script that backup a SQL database, but every time with different name (to keep the last 4-5 versions only). Right now I have a BAT, which just launch osql with a sql script, as below REM BAT file starts here "C:\Program Files\Microsof...

osql -S not giving me expected results

I'm trying to write a program in Java that uses osql to generate a list of databases on a server. My code is as follows: public Object[] findDataBases(String server, String user, String passwd){ str = new String[] {"cmd.exe", "/c", "osql", " -S ", server, " -U", user, "&&", "-P ", passwd, ...

[ODBC Driver Manager] Data source name not found and no default driver specified

I am trying to connect to list the servers on my network using osql.exe -L. Instead of a list of servers, however, I get the following error: [ODBC Driver Manager] Data source name not found and no default driver specified I'm not sure what's causing this problem - any pointers leading in the right direction will be helpful. Thanks so ...

Which dll's are required to run osql.exe as a standalone?

According to the accepted answer to this question, the osql.exe utility can be run as a standalone program on a computer without SQLServer, simply by copying the binary file to the new computer. My question is, however, which other files need to be copied along with osql.exe for it to work? Thanks so much! ...

@@ROWCOUNT in OSQL returns different result than in TSQL

I am experiencing some strange behavior with OSQL, and would appreciate any help. I have a batch file that will copy a database field from one column to another. Here is a sample script: SET NOCOUNT ON; UPDATE Table1 SET Table1.EmailAddress = Table2.GenericField FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.ID WHERE GenericFiel...

How to get results from OSQL.exe without dash characters from the command line?

Is there a way to send a osql query from the command line that returns results that do not include the big long line of dash characters that represent the column width? Here is the sample code I am working with: echo. "%PROGRAMFILES%\Microsoft SQL Server\%SQLVER%\Tools\BINN\osql" -S . -E -Q "SELECT name + ', ' FROM sysdatabases order b...

Error using osql.exe (Sql Server 2005)

I use sql server 2005 enterprise, windows server 2003. I try execute osql.exe command, for execute sql file in my server DESSQL: osql.exe -E -n-1 -i"CarpetaUno\TextFile1.sql" I get this error: Msg 102, Level 15, State 1, Server DESSQL, Line 1 Incorrect syntax near 'n' UPDATE: I try this too, osql.exe -E -i"CarpetaUno\TextFile1.s...