Pages

Tuesday, 15 January 2013

Delay Function in SQL Server

The Delay function used to execution of a batch in block, stored procedure, or transaction until a specified time or time interval is reached, or a specified statement modifies or returns at least one row.

While executing the WAITFOR statement, the transaction is running and no other requests can run under the same transaction.

Remarks:
Ø  If a query cannot return any rows, WAITFOR will wait forever or until TIMEOUT is reached, if specified.
Ø  WAITFOR statements not used in Views and Cursor.
Ø  When the query exceeds the query wait option, the WAITFOR statement argument can complete without running. You can create a Deadlock by running a query with WAITFOR.

Example:
SELECT GETDATE() CurrentDateTime
WAITFOR DELAY '00:00:05' ---- 5 Second Delay
SELECT GETDATE() CurrentDateTime


Note: You can also perform update, DB Backup and Restore and many important operation easily using this command.














Monday, 14 January 2013

What is X and Z report in POS(Point of Sale)

The format and contents of X report and Z report are mostly same. It may contain following main content and it may vary based on requirement:
1) Date and Time the report was perform
2) Identification Information (Shift/Batch related information)
3) Opening and closing balance
4) Discount, Total sales, Void transaction and many more
5) Tax, promotions, vouchers related information etc

Now the main question is what is the difference between X report and Z report, which is listed below:
X Report
Z Report
It shows current shift/batch information in details without closing shift/batch.
It closed current running shift and open new shift.
User can print it any time in a day to check transaction details.
It’s more preferable to print it at the end of day.

Sunday, 6 January 2013

SET FMTONLY in SQL Server

It returns only SQL table definition to user. It can be used to test the format of the response without actually running the query. It returns the column information only; no rows of data are returned.

Syntax: SET FMTONLY { ON | OFF }

1) SET FMTONLY ON Example:














2) SET FMTONLY OFF Example:




Sunday, 23 December 2012

Fun with GO Command of SQL.

In previous post, I explained using of “GO” command.
In this post i am going to explain how to rename “GO” command and use another word that you want as a batch separator.

STEPS:
Tools à Options…à Query Execution à SQL Server à General.

Suppose if i rename 'GO' to 'MYGO' then it can be use in following way:

         



















Saturday, 22 December 2012

GO Command in SQL

GO is not a T-SQL statement. GO is a command used for signalling the end of a SQL batch. Batch is nothing but a group of one or more Transact-SQL statements at the same time from an application to SQL server for execution.
GO is a utility command that requires no permissions. It can be executed by any user.
Please refer below image for more idea:


Difference between DataView.Table and DataView.ToTable

Both DataView.Table and DataView.ToTable return a DataTable from a DataView.
DataView.Table: It gives you the underlying data, with no changes from the dataview's sorting or filtering.
DataView.ToTable: It gives you the data in the dataview after filtering and sorting.

Please refer following image for more details:


Saturday, 8 December 2012

The Spatial Result tab in SQL Server.

Many days ago, i found very interesting feature of SQL server 2008 and above which is Spatial Result Tab so today i am going to show that feature.

SQL Server Management Studio 2008 and above introduces a new feature, the Spatial Results tab, which allows you to visualise the results of ad-hoc spatial queries directly in SQL Server Management Studio. To see the new Spatial Results tab, you simply need to execute and SELECT query that selects at least one column of geometry or geography data.

After you execute SQL query, you will be able to see something which is shown below image:


Download Query