Datameer Blog

Tag: SQL FAQs

SQL FAQ Feat

How to use IF condition in SQL SELECT statement?

In SQL Server, we have below two options to implement IF condition in SQL SELECT statement. CASE WHEN… THEN IIF Let us consider the following ‘student’ table. CREATE TABLE student ( student_name VARCHAR(50), grade CHAR(1) ) INSERT INTO student SELECT ‘Jack’, ‘A’ UNION ALL SELECT ‘Rose’, ‘B’ UNION ALL SELECT ‘John’, ‘C’ UNION ALL SELECT […]

  • SQL FAQs
  • February 1, 2019
SQL FAQ Feat

How to initialize an AUTO_INCREMENT column in MySQL?

The value of AUTO_INCREMENT can be reinitialized using the below methods. ALTER TABLE… AUTO_INCREMENT TRUNCATE TABLE Let us consider the table below. CREATE TABLE student (     student_id INT PRIMARY KEY AUTO_INCREMENT,     student_name VARCHAR(50) ); INSERT INTO student(student_name) VALUES (‘Jack’); INSERT INTO student( student_name) VALUES (‘Rose’); 1. ALTER TABLE… AUTO_INCREMENT We can […]

  • SQL FAQs
  • February 1, 2019
SQL FAQ Feat

How to add an IDENTITY to an existing column in SQL?

There is no straightforward way to add IDENTITY to an existing column. We need to follow a series of steps to achieve this. There are two ways to do this. Creating New Table Creating New Column We need to convert the ‘student_id’ column of the table below to an IDENTITY column. CREATE TABLE student ( […]

  • SQL FAQs
  • February 1, 2019
SQL FAQ Feat

How to get only the DATE part from the DATETIME in SQL Server?

In SQL Server 2008 and above, we can either use the CONVERT or CAST function to return the DATE part from the DATETIME datatype. — using CONVERT function SELECT CONVERT(DATE, ‘2010-12-20 22:52:43.133’) DateOnly — using CAST function SELECT CAST(‘2010-12-20 22:52:43.133’ AS DATE) DateOnly — Output DateOnly ————— 2010-12-20 In the older version of SQL Server, […]

  • SQL FAQs
  • February 1, 2019
SQL FAQ Feat

How to escape a single quote in SQL Server?

The most simple way to escape a single quote in SQL Server is to pair it with another single quote. Below are some examples: — For selecting: [My name’s Jack.] SELECT ‘My name”s Jack.’ escaping_quote — Output escaping_quote ——————– My name’s Jack. — For selecting: [‘My name’s Jack.’] SELECT ”’My name”s Jack.”’ escaping_quote — Output […]

  • SQL FAQs
  • February 1, 2019
SQL FAQ Feat

How to create an AUTO_INCREMENT column in a table on Oracle DB using SQL?

Before Oracle 12c, we don’t have a direct method of generating an AUTO_INCREMENT column in a table. We need to use the combination of Sequences and Triggers. Now, we have two different ways to implement it. Using IDENTITY column There are three options on IDENTITY COLUMN BY DEFAULT AS IDENTITY ALWAYS AS IDENTITY BY DEFAULT […]

  • SQL FAQs
  • February 1, 2019

Instant Access To Our Free Library Of Resources

Discover the Top ETL and Data Integration Platforms

Comparison_of_Leading_ETL_And_Data_Integration_Platforms

Featured Blog Posts

Five Critical Success Factors To Migrate Data to Snowflake
Five Critical Success Factors To Migrate Data t...

You’ve decided to modernize your data and analytics stack and migrate analytics workloads to the ...

  • John Morrell
  • May 10, 2021
ETL++
ETL++: Reinvigorating the Data Integration Market

(This article first appeared on Medium on April 6, 2021.) The definition of “++” means incrementa...

  • John Morrell
  • April 12, 2021
Spectrum ETL
Disrupting the no-code cloud ELT market: Datame...

More than just loading Data: Datameer launches Datameer Spectrum ETL++ to disrupt the no-code clo...

  • Press Release
  • February 9, 2021
READ ALL