How to use Asp.net
  • Home
  • About us
  • Disclaimer
  • joy of helping
KEEP IN TOUCH

how to use isnull(), if, else if, while loop, return, select case in sql server

Apr21
2012
Leave a Comment Written by vikram

– Here i m writing how can we use
–1. delay/timer
–2. goto
–3. isnull()
–4. select case
–5. while loop
–6. return
–7. if else
–8. if else if
– in sql server.

–1. using WAIT FOR
Select ‘Before Delay’ as [wait/delay]
WAITFOR DELAY ’00:00:05′ — will wait for 5 seconds
Select ‘After Delay’ as [wait/delay]

————–
–2. using How can we use go to statement
– using GOTO statement
GOTO a
select ‘not accessing’ as [goto]
a:
select ‘accessing call2′ as [goto]

——————
–3. using ISNULL
declare @a1 int
set @a1 = null
select ISNULL(@a1,0) as [isnull]

——————-
–4. using SELECT CASE
declare @a2 varchar(50)
set @a2 = ‘ok’
Select CASE
when @a2 = ‘true’
then ’1′
else ‘false’
end as [select case]

———————-
–5. using WHILE LOOP
declare @a3 int
set @a3=1
while(@a3 < =2)
begin
select @a3 as [While Loop]
set @a3 = @a3+1
end

—————–
–6. using return
declare @a4 int
set @a4=1
while(@a4 < =10)
begin
select @a4 as [return]
if (@a4 = 2)
return — you can use here GOTO also
set @a4 = @a4+1
end

—————–
–7. using if else
declare @a5 int
set @a5=1
if(@a5=1)
select ‘true’ as [if else]
else
select ‘false’ as [if else]

—————–
–8. using if elseif kind of select case statement.
declare @a6 int
set @a6=3
if(@a6=1)
select ‘true’ as [else if]
else if(@a6=2)
select ‘in else 1′ as [else if]
else if(@a6=3)
select ‘in else 2′ as [else if]
else
select ‘in else’ as [else if]

with regards

vik

Posted in Sql Server
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« How to Upload and crop images with jquery in ASP.NET C#
» how to create match the following concept with jquery

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Joy of Helping

Any sort of help to the children who are fatherless, poor & are from far-off areas.
Joy of Helping

Facebook Link

Asp dot Net ,Ajax,Xml.

Recent Posts

  • ROW_NUMBER(), NTILE(), partition by, Duplicate Records, CTE sql server 2008
  • How to get second highest Salary sql server 2008
  • Insert values, insert into, insert default value, insert execute and select into sql server 2008
  • How to Bind GridView with SqlDataReader in Asp.net
  • how to attach files to email without storing on disk using Asp.net FileUpload control

Recent Comments

  • Anonymous on ROW_NUMBER(), NTILE(), partition by, Duplicate Records, CTE sql server 2008
  • dhananjay on How to use GridView with Insert, Edit, Update, Delete the Ado.net way C#
  • dev on How can we limit the characters in multiline textbox asp.net using JavaScript
  • navneet on How to display image in Image control after upload on the server asp.net C#
  • AnhVu on How to do Shopping Cart in Asp.net C#

Archives

  • February 2013
  • September 2012
  • April 2012
  • January 2012
  • October 2011
  • August 2011
  • May 2011
  • April 2011
  • March 2011

Categories

  • Asp.net
  • jQuery
  • Sql Server

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

EvoLve theme by Theme4Press  •  Powered by WordPress How to use Asp.net