Blog
Cancel

Using NULLIF function

drop table #budgets CREATE TABLE #budgets ( dept tinyint IDENTITY, current_year decimal NULL, previous_year decimal NULL ); INSERT #budgets VALUES(100000, 150000); ...

Generate sequential number using row_number function

-- Example of how to use row_number to generate sequential number starting from 0 by group create table #test(names varchar(100) ) 2 insert into #test select 'Suresh'union all select 'Ramesh' un...

Handling exceptions in WPF

Handling exceptions in WPF WPF lets you handle all unhandled exceptions globally. This is done through the DispatcherUnhandledException event on the Application class. <Application x:Class="De...

Display list of customers using a Datagrid

MainWindow.xaml Add a DataGrid to MainWindow.xaml Set its ItemsSource property to a CollectionViewSource Define a CollectionViewSource. Name it with a key and set the Source property to Bin...

WPF - Routed Events

Routed events - WPF A routed event is a type of event that can invoke handlers on multiple listeners in an element tree rather than just the object that raised the event. <Window x:Class = "WP...

Simple layout - 3 buttons vertically

MainWindow.xaml <Window x:Class="SimpleLayout.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml...

Control Template for a button

In this example, a control template is set explicitly on a button to change the way it appears. window1.xaml <Window x:Class="ButtonTemplate0.Window1" xmlns="http://schemas.microsoft.com...

Insert results of stored procedure into a temporary table

-- insert results of stored procedure into a temporary table DECLARE @return_value int declare @temp table(DeliveryDate DateTime, OptionDateTime varchar(10)) insert into @temp EXEC dbo.RR_GetDebtA...

Insert with EXISTS condition

// The following is an example of an insert statement that utilizes the EXISTS condition: INSERT INTO suppliers (supplier_id, supplier_name) SELECT account_no, name FROM suppliers WHERE exist...

Using COALESCE

-- Note: COALESCE returns the first nonnull expression among its arguments. ALTER PROCEDURE [dbo].[MDR_UpdateCurrencyDiscountIndex] @Currency varchar(3), @DomesticDiscountIdx varchar(50)= NULL...