Skip to main content

Posts

Dynamic SQL Statements in SQL Server

Sometimes we need flexibility of using dynamic database name(s) in PL/SQL Statements. We might have an application where the database(s) are given an option in the drop downbox and the user can select any one. Based on the selection, another drop downbox shows all the tables in that database. In order to achieve the same, dynamic execution of sql statements can be used in SQL Server: declare @vDatabasename varchar (5 0 )          set @vDatabasename = 'Example' EXEC ( 'Select * from [' + @vDatabasename + '].sys.Tables' )

Delegates in VB.NET

Delegates in .NET Framework are equivalent to Function pointers in C and C++ language. Delegates helps in multithreaded application where one thread is accessing a UI element created by another thread. For e.g. the follwoing code will always return an error of type " Cross-thread operation not valid: Control 'TextBox1' accessed from a thread other than the thread it was created on." Imports System.Threading Imports System.Reflection Public Class Form1     Private trd As Thread     Private Sub Button1_Click( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles Button1.Click         trd = New Thread ( AddressOf DoTask)         trd.IsBackground = True         trd.Start()     End Sub     Private Sub DoTask()         Dim i As I...

Metro inspired User interace used by Microsoft in HTML 5.

Microsoft is embedding the tile based user interface not in only in XBOX or next gen Windows, rather it is being tested on the web also. The screenshot given below shows how exactly it looks like: If somebody wants to see the action for himself/herself, please follow the link below and give me your valuable opinion: http://www.microsoft.com/windows/windowslive/whatsyourinboxlike/ Hope this tile based interface brings uniformity in all the Microsoft products.

Comma Separated Values with XML in SQL Server

There are situations when we want the data to be presented in the comma separated values rather than individual rows. For e.g. see the data in the pic given below: The above shows all Enames with its deptno. But the employees for each deptno is represented as an individual row. Now if we want to display the same data with comma separated values given in the screenshot below: In order to achieve this, we can use the XML Path function in SQL Server. This will help in generating the individual values and we can separate individual values with the help of comma or any other identifier. The query to generate the above resultset is: In the above query we have used substring function so as to remove the "," which comes at the start of every name. The above is a wonderful tool to rearrange the values in the form of comma separated values.

Windows 8 Tablet interface shown.

Microsoft has previewed the Windows 8 Tablet interface that will be used in the small form factors pcs/notebooks etc. and will run on ARM and other low energy chips. Microsoft has completely redesigned a new look for the tablet form factors that is a paradigm shift from other versions of Windows. The interface is inspired from the Windows Phone 7 Metro UI.  Windows 8 will also support the classic interface for running legacy applications. View Windows 8 Tablet interface

Common Table Expressions in SQL Server - CTE

A common table expression (CTE) can be thought of as a temporary result set that is defined within the execution scope of a single SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. Unlike a derived table, a CTE can be self-referencing and can be referenced multiple times in the same query. In simple layman's terms, CTE basically provides data at the runtime which may come from multiple tables.  For e.g. if we have different tables like emp, dept, salgrade etc. then CTE can help in getting the resultset/dataset from multiple tables and form a temporary table. Then we can refer this table within other query any number of times.  For e.g. if we want to display the following: Deptno Dname Location TotalCount 10 Hotel Management Amritsar 6 20 Information Technology Chicago 1 30 Finance Ludhian...