Skip to main content

SQLCMD command line utility

Recently I work with SQLCMD utility and it is quite interesting. You can enable it in your Management studio as follows;

sqlcmd_1

Then you can make use color coding and syntax highlighting as well . Other than this ,you can enable this SQLCMD mode in your normal command line by setting path variable to binn folder as following example

C:\Program Files\Microsoft SQL Server\100\DTS\Binn\

Then just open command line and then type this command.It will show the option available;

-sqlcmd –?

sqlcmd_2

To connect to a database and query for data

sqlcmd -S ERANGA-PC\SQLEXPRESS -d T1 -U sa -P Qwer1234 –q “Select * from Student”

Comments

Popular posts from this blog

The transaction is in doubt

Sometimes you may get this error when you use transaction scope . The transaction is in doubt I also got this error recently and able to find the reason for it. That is because of the some of the readers had not properly disposed. Actually in this case you can use Using keyword to overcome this. Exception : System.Transactions.TransactionInDoubtException was unhandled by user code Message="The transaction is in doubt." Solution : using (reader) { }

MySQL Stored Procedure Error

In our project we had many many stored procedures and many parameters passes to those sps. But in only one sp it gives error message something like this; "Incorrect number of arguments for PROCEDURE sproc_t_l_Contract_Select_BySearchCriteria; expected 3, got 2” Work long time on this sp but coudnt find it. So i tried to write it again from the begining. In this time it was work perfectly.This problem occurs because of the space between data type and its length. Ex. pName varchar(50) - working pName varchar (50) - Not working But it does not mention syntax error or something.So this error message make us vulnerable.