Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I need to select a value from my "customers" data table. I faced this question in an interview.

Select cust_Name from customers where cust_Id=5;

This query will result as "Naresh".

However, now I need to print the value as:

Customer Name is Naresh

How to print the value like this?

1 Answer

0 votes
by (12.7k points)

You can use this following code:

Select 'Customer Name is ' + cust_Name from customers where cust_Id=5;

Or also you can use this:

Declare @CustomerName varchar(50)
Select @CustomerName = cust_Name from customers where cust_Id=5;
Print 'Customer Name is ' + @CustomerName ;

Want to be a SQL expert? Join this SQL Training course by Intellipaat to learn more.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.7k questions

32.8k answers

500 comments

109k users

Browse Categories

...