Posts

Showing posts from September, 2013

Get inserted or deleted records in SQL - OUTPUT Clause

In SQL, how we identify the last inserted or deleted records? We’ve used @@identity to get the last inserted records identity value. This will not be sufficient while insert lot of records in same time. To solve that, we have OUTPUT clause to get the inserted/deleted data information. Especially this OUTPUT clause is very useful while using MERGE clause. Since this is the only way to get inserted/deleted records in TARGET table. OUTPUT Clause: Returns information from, or expressions based on, each row affected by an INSERT, UPDATE, DELETE, or MERGE statement. These results can be returned to the processing application for use in such things as confirmation messages, archiving, and other such application requirements. The results can also be inserted into a table or table variable. Additionally, you can capture the results of an OUTPUT clause in a nested INSERT, UPDATE, DELETE, or MERGE statement, and insert those results into a target table or view. Ref:   http://...

Tricks to eliminate GROUP BY problems in SQL

Most of us having trouble with using GROUP BY clause in SQL. GROUP BY class is painful, because we cannot select the columns other than the columns used in GROUP BY. We have another concept to get rid of GROUP BY clause problems. The OVER ( PARTITION BY column_name) will work like a GROUP BY clause, and we can do the same with this clause without any limitation of GROUP BY.   Can we use any aggregate function without using GROUP BY? Yes. We can. Please execute the below SQL query sample to know about OVER ( PARTITION BY … ) class. Sample: IF OBJECT_ID ( 'tempdb..#student_details' ) IS NOT NULL       DROP TABLE #student_details       CREATE TABLE #student_details (        student_id UNIQUEIDENTIFIER       , student_ident INT IDENTITY ( 1 , 1 ) PRIMARY KEY       , student_name VARCHAR ( 15 ) ) GO DECLARE @du...

SignalR(Push Services) – Part 2

Explained about SignalR clients and consuming SignalR with various clients( Web, Windows and Windows Phone) Hub Clients Hub consumers can be classic client application or other service/hubs SignalR provides variety of client libraries(.Net4.0+, WinRT, WindosPhone8, SilverLight 5, JQuery, c++) JQuery Client: SignalR JQuery plugin offers two approaches Proxy based with generated proxy Automated proxy code via signalr/hubs/ Scripts generated based on hubs declaration in .Net 'Contract' if you will Optionally: create static proxy file via signalr.exe tool Hubs become properties on $.connection E.g. $.connection.chatHub Hub name camel cased Without Proxy but 'Late binding' We can also use late binding approach Simple steps Create Hub Connection Get dynamic Proxy Proxy = $.hubConnection().createHubProxy("Chat"); proxy.on(''newMessage', onNewMessage); Wire up events based on method/event...

SignalR (Push Services with Hubs)–Part 1

ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data. Push services is something like whenever data changes in any of the devices (web, mobile, ssms) the data displayed on other devices will be updated instantly. Push Pattern: Push services are not an official pattern. Technical approaches for push Periodical polling Long polling Forever Frame Service Sent Events (SSE) Web Sockets SignalR: A server side framework to write push services A set of client libraries to make push services communication easy to use on any platform Optimized for asynchronous processing Two Programming Models Persistent connections Hubs NOTE: SignalR packages are available through NuGet ...