Monday, June 20, 2016

Run Stored Procedure from Batch file (MS SQL & Oracle)

In this post we will lean how to run a stored procedure from a batch file (.bat) externally. This is used very often to run a schedule job set in the server. The whole job logic is written in the Stored procedure and we are executing that from an external batch file. So what we have to do to run this, lets see.

We will use the sqlcmd.exe file to run the stored procedure from command.  First of all create a Stored procedure in your MS. SQL server.

      print 'THIS IS A TEST MESSAGE. LOGGED AT ' + CONVERT(VARCHAR, getdate(), 120)

I named this as SP_TESTSP, go with your name and now open a Notepad or any other editor and write down the following script.


As my server name "arka-PC\SQLEXPRESS" and using Database as "DEMO", so in this case the command will be,

sqlcmd -Q "exec SP_TESTSP" -S arka-PC\SQLEXPRESS -d Attendance -o D:\SPOutput.txt

Before run this script create a file name with SPOutput.txt in the D:\ drive or where you want to save. The output of the stored procedure will be captured.

Now save the file with an extension of  ".bat". Set all the privileges and run the file by clicking twice. Check the log file, it will contain the result of the executed stored procedure.


THIS IS TEST MESSAGE. LOGGED AT 2016-06-19 23:52:48

In the next tutorial we will see how to put a bat file in a Task Scheduler in windows server.

Sunday, April 17, 2016

How to prevent F12 in browser


Opening the console log of browser and change element value of a web page is like a headache for the developer. To prevent this situation here is the remedy.


So how to stop this kind of situation, you could get a message while user is opening the console log and take necessary step or you could prevent user from opening that. We will discuss both the situation in this article one by one.

Getting noticed while opening the console of the browser:

Create a normal HTML page and and add a div to show the status of the development tool box. And write down the code.

    status: <div id="status"></div>
After that write down the code within the script tag under body section.

    var checkStatus;

    var element = new Image();
    element.__defineGetter__('id', function () {
        checkStatus = 'on';

    setInterval(function () {
        checkStatus = 'off';
        document.querySelector('#status').innerHTML = checkStatus;
    }, 1000)


Prevent Clicking F12 and Mouse Right Click:

This trick is not like showing status. By showing status you can do all your customization in your code but here in this example of coding user will not be able to click F12 and mouse right click. Lets see how.

Before starting add JQuery into your page. To add it add the bellow script to the top of all the JQuery code.

<script src=""></script>
After that within a script tag write down the  bellow code.

    $(document).keydown(function (event) {
        if (event.keyCode == 123) {
            return false;
        else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
            return false;

    $(document).on("contextmenu", function (e) {

As you can see we have used the Key code to detect the clicking of buttons and mouse. Here 123 stands for F12 and 73 for I key. To know more visit

Run both the examples and enjoy.


Follow by Email

Popular Posts