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 fetching 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 *
SELECT * FROM dbo.[TestEmp]; GO
Using Other Single Special Characters except *
SELECT £ [£],$ [$],€ [€],¢ [¢], ¥ [¥],₱ [₱],\ [\] FROM dbo.[TestEmp]; GO
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
To Find Datatype
To find the above mentioned symbol’s datatypes, we can use View Table Structure method like below.
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';
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.