List/Grid SQL Server Subscribe RSS feed of category SQL Server
How To Find the SQL Server Instance Name and Machine Name using Query in SQL Server
You can easily, with just a single query of 4-5 words, fetch your Machine name and SQL Server Instance name. Machine name is the one which can be find by right clicking your Computer and then selecting Properties from the right click context menu and SQL Server Instance name is the one to which you are currently logged in, in your SQL Server. Actually you can have multiple Instances of…
How To Generate Random String / Password In SQL Server
In this article, I will discus about the While loop in SQL Server and will show you how can we generate random numbers/characters in SQL Server to get a random string. Application of this process can vary but the procedure is same. You can use this method to generate random passwords, to generate confirmation code or something like that, user ids etc. Main concept of this procedure is getting random…
How To Check if A String is Valid IP Address in SQL Server
For security purposes, some websites saves IP addresses of its users in the database. Your web application will send you a string value (Varchar value), and you have to save that value in your database. Before saving you can cross check whether the value supplied is correct or not. In this article, I will show you how can we check the string value in SQL Server, whether the value is…
How To Generate Random Numbers In SQL Server
Sometimes you need to generate Random numbers for some kind of functionality in SQL Server. Say you want to create an application to select Lucky Draw winner for any kind of competition from your database. Then you can achieve the same by generating a random number and then selecting that row or person from your database. Here is my article on How To Select nth Row from a Table. Instructions:…
How To Create View In SQL Server, the Easy Way
We know about the ultimate Visual Interface Microsoft’s SQL Server has and today I will discus about using this Visual Interface to create Views an easy way. Views are the virtual tables, and data in them is not actually reside in your hard drive corresponding to your View. The data is just a mirror image from one or more Table which may even belong to different database. You can select…
How To Select nth Row From A Table In SQL Server
In this article I will show you how can we select nth row based on our requirement from a SQL Server table. Steps needed for this is first of all, select top n rows first from that table, then select the topmost row which is the nth row in those selected n rows. I will be using SQL Server 2008 R2 and AdventureWorks database to describe things. Have a look…
How To Delete A SQL Server Table Using T-SQL
You can delete SQL Server table using the user interface by right clicking the table you want to delete and then selecting Delete. But if you want to delete that table using T-SQL or query then you can use DROP statement in SQL Server to drop / delete a table. Instructions: Here is an example to delete an existing table from your database. USE HowToIdeas GO DROP TABLE [abc] GO
How To Find Size Of Database In SQL Server
When you create a new Database, at that time you can mention how much sizeb this database should use initially. That much size your database will use till all of that size don’t get used. In the following figure, new database will use 4MB of size by default, whether it will have that much data in it or not. But once the database gets data of that much size it…
How To Copy A Table In SQL Server Using T-SQL
In this tutorial, I will show you a quick and easy to create clone of an existing SQL table in a new table. During copying a table, we can also control that whether the whole data should be copied into new table or just the table structure. But when we create clone of a table, that will not copy all the constraints in the new table but it will copy…
How To Create A Table In SQL Server Using T-SQL
Today I will discus about how can we create a Table using T-SQL or Query System in SQL Server. Before creating a New Table in a Database, you must verify that, there is no other Table existing in that Database with the same name. You can check my another article on How To Check If Specified Table Exists In SQL Server Database. Instructions: Check whether a Table with same name…