There are couple of ways in which you can retreive the version of the SQL Server using T-SQL. Checking the version of a SQL Server using T-SQL 1. using @@VERSION 2. Using SERVERPROPERTY function as shown
Assume a scenario where you have a column in your table in SQL Server database where you want to retreive the first character of the column value. How to get the first character of a string in SQL Server ? You can use the LEFT function and specify the column name as well as the […]
When working with the SQL Server Management Studio and trying to edit the table records , you would have noticed the context menu option “Edit Top 200 Rows”. How do you change this to display all the records for editing instead of “Edit top 200 rows” in the context menu ? There are couple of […]
If you need to check if a login exists in SQL Server , you can use query the master.dbo.syslogins for it. How to Check if a login exists in SQL Server ? Here’s a sample query demonstrating how you can query master.dbo.syslogins to find out if the login exists in SQL Server. This would retreive […]
MySQL has the function Now() which is a Datetime type field which shows the current date as well as the time. What is the equivalent of MySQL’s Now() function in SQL Server ? In SQL Server , you can use the GetDate() function to achieve the same.
If you want to get the first day of the month of a input datetime variable from a SQL Query , here’s how you do it.
You can retreive the date in the YYYY-MM-DD format in SQL Server using the CONVERT method as shown in this code snippet. How to get the date in YYYY-MM-DD format in SQL Server ?
There are times when you get an error stating “Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.” You […]
You can find out if the index exists for a table by querying the sys.indexes table as shown in this blog post’s code sample. How do you check if an index exists in a table? This will list out all the indexes of the table.
You can use the TOP keyword and specify the number to retreive the TOP N records that the query returns. Additionally , order the records by newid() function using the ORDER BY clause to make the records random. How to select N random rows using a T-SQL Query ?