i have account table which consists of account name,card no
and card no consists 16 digits now i want to retrieve the
data if card no starts from 4 then it should print visa and
if it starts from 5 then it should print master so plse help
me to write simple query with out store procs .

Answers were Sorted based on User's Feedback



i have account table which consists of account name,card no and card no consists 16 digits now i wa..

Answer / rajesh bhawsar

select name,
(case left(cardno,1)
when '4' then 'visa'
when '5' then 'master'
end) as result from account

Is This Answer Correct ?    5 Yes 1 No

i have account table which consists of account name,card no and card no consists 16 digits now i wa..

Answer / rahul

hi every one.

select name,
case
when card_no like'4%' then 'visa'
when card_no like'5%' then 'master'
end result from account;

Is This Answer Correct ?    4 Yes 1 No

i have account table which consists of account name,card no and card no consists 16 digits now i wa..

Answer / kiranu

Hi every one

select name, cardno(case substring(cardno,1,1)when '4' then
'Visa' when '5' then 'Master' end) as Result from account;

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is public role in sql server?

1 Answers  


what's new in sql server 2016?

1 Answers  


Can sql server be linked with other servers like oracle?

1 Answers  


What is built-in/administrator?

1 Answers  


Is index a datbase objects in sql server?

2 Answers  


Where are SQL server users names and passwords are stored in sql server?

1 Answers   HCL,


What are a scheduled jobs?

1 Answers  


Who developed sql server?

1 Answers  


How to change server name in sql server?

1 Answers  


What is the difference between set and select?

1 Answers  


difference between function and procedure

3 Answers   Cognizant, HCL, TCS, Theorem,


there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration

1 Answers  


Categories