Alternatives · Play in SQL

Single Digit Special Characters used between SELECT and FROM in SQL Server

Introduction

In this blog post, we are going to see what are the single digit special characters we can use between SELECT and FROM in SQL Server. Yup, many of us would guess and say ‘*’ (Asterisk) . Yes, of course it’s right and it will be our first answer. But What if my question is what other special characters except ‘*’ ?

Single Digit Special Characters used between SELECT and FROM except *

Many of us uses ‘*’ (Asterisk) as Single Digit Special Characters in our day-to-day life for the purpose of bringing up all columns from our tables and written queries in SQL Server.

SQL Script – Sample Table Creation with Data

--Sample TABLE Creation with Data
IF OBJECT_ID('..TestEmp') IS NOT NULL
	DROP TABLE [TestEmp];
CREATE TABLE dbo.[TestEmp] 
(
	TestEmp_Key INT IDENTITY(1,1) NOT NULL,
	EmpName VARCHAR(100) NOT NULL
);
GO

INSERT INTO dbo.[TestEmp]
(EmpName)
VALUES
('Arulmouzhi'),('AlveenaJoyce'),('Madhivanan');
GO

Using Asterisk *

SQL Script

SELECT * FROM dbo.[TestEmp];   
GO

Image Pic

Using Asterisk *

Using Other Single Special Characters except *

SQL Script

SELECT 
£ [£],$ [$],€ [€],¢ [¢],
¥ [¥],₱ [₱],\ [\] FROM dbo.[TestEmp];   
GO

Image Pic

Using Other Single Special Characters except *

List

Some of the Special Characters used in SQL Server

NOTE

Like mentioned in the above query, we can use some of the currency symbols just like * between SELECT and FROM in SQL Server. Above mentioned are some of the Currency Symbols that SQL Supports.

SQL Script – Example

SELECT 
£1 [£],$2 [$],€3 [€],¢4 [¢],
¥5 [¥],₱6 [₱],\7 [\];   
GO

Image Pic

Currency Values

To Find Datatype

To find the above mentioned symbol’s datatypes, we can use View Table Structure method like below.

SQL Script

IF OBJECT_ID('TEMPDB..#A') IS NOT NULL
	DROP TABLE #A;
SELECT 
£1 [£],$2 [$],€3 [€],¢4 [¢],
¥5 [¥],₱6 [₱],\7 [\] INTO #A;  
--SELECT * FROM #A;
EXEC TEMPDB..SP_HELP '#A';

Image Pic

Money Datatype

Conclusion

Thus, we saw what are the other single digit special characters except * and their datatypes that we can use between SELECT and FROM in SQL Server. The above Scripts ran and Unit tested in both On-premises and Azure SQL DB.

Thanks for reading! FOLLOW BLOG for Interesting Upcoming Posts!

Advertisement

3 thoughts on “Single Digit Special Characters used between SELECT and FROM in SQL Server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s