Quick introduction to SQL, databases and relational theory — Parv The IT Geek

Many people find it daunting when they think about Databases and SQL. I know I found it very scary in the beginning and my early experiences with Database developers left me feeling very small and I thought that maybe I was not good enough to succeed in this field. However, I was luckily given aContinue reading “Quick introduction to SQL, databases and relational theory — Parv The IT Geek”

How to change the collation of a database in SQL Server? — Parv The IT Geek

Have you ever wondered how to change the collation for a database in SQL Server? Well the other day I received a database from a third party supplier and the first step was to change the Collation of the database. My questioning about why they would supply the database in the incorrect collation setting wasContinue reading “How to change the collation of a database in SQL Server? — Parv The IT Geek”

SQL Server Collations Find current collation and all supported collations — Parv The IT Geek

Have you ever needed to check your database or SQL instance to find out its collation? Have you ever wanted to check whether a collation is supported by Windows or SQL Server? Well I am going to show you how to find out the information quickly and easily. The below query will show the instanceContinue reading “SQL Server Collations Find current collation and all supported collations — Parv The IT Geek”

ASCII String function in SQL Server — Parv The IT Geek

Have you wondered what the ASCII value of a character is whilst using SQL Server? Or needed to quickly check the ASCII value? Or wondered how the ASCII Function worked? Well the other day I saw one of the developers using the ASCII function which I was not familiar with so I decided to aContinue reading “ASCII String function in SQL Server — Parv The IT Geek”

Statistical Aggregate functions in SQL Server — Parv The IT Geek

Have you ever wondered how to do program or perform simple statistical function within SQL Server? Well the kind people at Microsoft have enabled us to all to save time by giving us a few inbuilt functions which save us from having to solve them programmatically. I have used the unit Price column in the SalesOrderDetailContinue reading “Statistical Aggregate functions in SQL Server — Parv The IT Geek”

SQL Cursor to Kill all connections to a database — Parv The IT Geek

Have you ever tried to restore over a database but found that all attempts are being blocked by an annoying SPID? Or had hundreds of orphaned SPIDs running crazy on your instance? Well I have the solution for you with the below script which uses a cursor to kill all connections to a database. DECLAREContinue reading “SQL Cursor to Kill all connections to a database — Parv The IT Geek”

SQL Cursors — Parv The IT Geek

Cursors are a way of manipulating data and interacting with them one at a time. They have a bad reputation within the SQL world as they go against the SET based logic and they can have a very high performance cost. Where possible you should ask yourself whether you could avoid using a Cursor. ThisContinue reading “SQL Cursors — Parv The IT Geek”

WHILE, BREAK, and CONTINUE Statements — Parv The IT Geek

Have you ever wondered how to create a loop in SQL? Or wondered how to break and escape a loop? Well I am going to briefly introduce you to the WHILE, BREAK, and CONTINUE Statements which will satisfy your curiosity The first command I will introduce you to is WHILE DECLARE @i int = 1;Continue reading “WHILE, BREAK, and CONTINUE Statements — Parv The IT Geek”

Learn about the WAITFOR TIME & WAITFOR DELAY — Parv The IT Geek

Have you ever wanted to pause a command for a short period or wanted to run a transaction at a specific time. Well I am going to quickly show you how to do them both using the WAITFOR command. SELECT GETDATE() WAITFOR DELAY ’00:00:10′; BEGIN SELECT GETDATE() END; The above code shows you how toContinue reading “Learn about the WAITFOR TIME & WAITFOR DELAY — Parv The IT Geek”

Declaring Variables and Retrieving Variables — Parv The IT Geek

A variable can be best described as being a place holder for information which you then fill in with relevant information which you will want to retrieve later. The below query shows the result from the CURRENT_TIMESTAMP which returns the current date and time. PRINT CURRENT_TIMESTAMP Jan 15 2015 11:44AM The CURRENT_TIMESTAMP result can beContinue reading “Declaring Variables and Retrieving Variables — Parv The IT Geek”