Posts by Devsheet

Read all articles posted by Devsheet programmers and content writers.

SQL Server query to add auto increment field

If you're working with a SQL Server database, you may need to add an auto increment field at some point. This can be done using a simple query. In this article, we'll show you how to add an auto increment field to a SQL Server table using a query.

sqlcmd command to connect to a SQL server

The sqlcmd command is used to connect to a SQL server. This command can be used to run queries, create databases, and perform other tasks. In this post, we will learn how to connect to a SQL server using sqlcmd.

Case Insensitive SQL Select Query with WHERE clause

Mostly, in SQL you will come across to query used with a WHERE clause for searching records. But there are instances where some data may contain characters that are either lowercase or uppercase thus you need to develop case insensitive SQL queries.

SQL Query to delete rows that have different Ids or column values

SQL Query examples that you can use to delete multiple rows from a table that have different column values.

SQL Server query to get table structure and column information

You can get table columns information from INFORMATION_SCHEMA.COLUMNS.

MSSQL query to insert value which contains apostrophe or single quote

To insert a value which contains apostrophe or single quote in it, we can use extra single quote with the apostrophe as shown in the below code example.

Select only year from date field MSSql query

To extract year from a date in the MSSql Server you can use the year() method of MSSql.

Group by full example SQL query

Full example of 'group by' statement in SQL that we are using to find the sum of quantity for stock_company table based on price

Remove all tables from database using MSSQL query

MSSQL contains a store procedure - sp_MSforeachtable that can be used to remove or drop all tables from the database.

Searching or Like Query in Sql

Like query in SQL can be used to search through one column or multiple columns in a table.

Create or update records Mysql/Sql

In this post, we are going to explain the SQL query that will create the row if already does not exist and update it if a duplicate unique key is found.

Add unique key constraint on existing column Sql query

When adding a unique key constraint to an existing column in SQL, the column must first be converted to a data type that can hold only unique values. This can be done using the ALTER TABLE command. Once the column has been converted to the appropriate data type, the UNIQUE KEY constraint can be added using the ADD CONSTRAINT command.

INNER JOIN SQL Query

When working with databases, there are often times when you need to combine data from two or more tables. This is where the SQL INNER JOIN statement comes in handy.

Truncate table SQL query

If you need to delete all data from a table, you can use the TRUNCATE TABLE SQL query. This will delete all rows from the table and reset the auto-increment value to 0.

Rename table SQL command

In SQL, the RENAME TABLE command is used to change the name of a table. This can be useful if you want to change the name of a table to something more descriptive, or if you need to change the name of a table to conform to a naming convention.

Drop table SQL query

A drop table SQL query is a type of query used to remove a table from a database. This query is typically used when a table is no longer needed or when it needs to be replaced with a new table.

Loading more...
Search all posts...