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

Dead Code Problem

Problem Actually this problem occurred when i was doing integration two projects. [Phase1 and phase2 of a project] . Phase 2 is developed on top of the phase1. Parallel phase1 had changed lot . Mean time those were working on phase2 has commented existing phase 1 code without comments . Phase 1 and phase 2 merged with some conflicts. So we commented such places with the descriptive comment . After merged the result code base has merged those phase 2 commented parts. Also there was some of already dead code in phase 1. So it is difficult to understand weather this is actual dead code or commented one from phase 2. Mistake Had left dead dead code and missing comments . Lesson learned Normally developers leave dead code in their original code with the mind of future purpose. But this not a good habit to continue.As long as you use source control ,earlier code may exist. Problem will occur if you are not using such version control. In such a situation you can keep dead code with des...

Recurrent Work–Automate them

Problem Sometimes we do some recurrent works those can be automated. Few months back in a integration of two project I had to create multiple database scripts to merge those two. There are more than twenty scripts.Initially I run those one by one and it took long time to create the DB. Mistake We don’t care to automate those recurrent work .Just Do at the point you need. Once you get to know its recurrent you will regret I could have automate this. Lesson Learned By automating recurrent works [Those can automate] you can save your time