Examples of basic SQL commands and statements, simple queries.
- Concatenate in SQL Server - concatenate string values with CONCAT function.
- Convert rows to columns using CTE - transform rows into columns with CTE.
- Convert rows to columns using PIVOT - uses PIVOT operator to convert rows to columns.
- Create table - create new table in database.
- Create Temporary Table - create Local and Global temporary tables.
- Create Table with Primary Key - example of how to create table with primary key.
- Create Table with Foreign Key - example of how to create table with foreign key.
- Create Table with Primary Key autoincrement - example of how to define primary key autoincrement in a create table statement.
- Create Table with Primary key and Foreign key - show how to use primary key and foreign key in a create table statement.
- Check if table exists - check if table exists before create or drop table.
- Check if column exists in a table - verify if there is a column with the same name in the table.
- Check if column is not null or empty - verify if an existing column in the table is filled with values or is empty.
- Check if row exists in table - examples of how to check table rows.
- Check if index exists on column - uses sp_helpindex function.
- Check if string contains letters - search for letters in a string of characters.
- Date format DD-MM-YYYY
- Declare variable date
- Declare variable string
- Declare variable table
- Insert multiple rows
- Find duplicates rows
- Delete duplicates rows
- Drop table if exists
- Select records from a table
- Select from two tables
- How to add second to date
- How to add minute to date
- How to add hour to date
- How to add days to date
- How to add month to date
- How to add year to date
- How to extract data from an XML column
- How to list all nodes from an XML column
- How to insert XML into SQL table
- How to find percentage
- Get date difference
- Get month from date
- Get total number of rows
- Remove first n characters from string or column
- Convert SQL to JSON in SQL Server
- Split JSON data in a SQL Server columns
- Store JSON data in SQL Server
- Using Where clause with Order by
- XML SELECT child nodes dynamically
- SQL examples
- SQL Server examples