About Brumedishetty

I work as a SQL Server DBA. Look at the About Me page for more info

Why Learn SQL?

If you have not yet encountered SQL (structured Query Language), then you may not be aware of the advantages which can be had from learning this particular programming language for yourself. However, there are plenty of reasons why more and more people are choosing to learn how to use SQL for themselves. Here are just a few points to consider… 

Firstly, you should be aware that, over the years, SQL has become one of the most important and widely used programming languages around. You are more than likely to have accessed sites which use SQL without even realizing it. More importantly, if you are looking to create your own site, it is almost certainly something which you will want to have a good grasp of. Whether you are looking to put together a company site similar to o2.co.uk, understanding SQL can almost always be of an advantage. The better your knowledge and understanding of this programming language, the more comprehensive your site is likely to be. This can also enhance the user experience, and even increase the number of hits that you receive. 

For those who are looking to develop a career in programming, mastering a language like SQL can prove to be extremely valuable. Learning this language independently can be time-consuming and may require much determination, but it is certainly something which can make you a more attractive employment prospect to future employers. Using the step by step tutorials on this site, you can learn SQL at your own pace, and in your own home. This is a valuable skill to have on any programmers resume, whatever level they currently happen to be working at. SQL is a language which feeds into a range of other database languages, and so it is also something which can be hugely beneficial in being able to enhance your existing programming knowledge. 
 
– Bru Medishetty

Alter an existing object rather than Drop and Create

In this blog I would like to write on a topic that I see many developers (and few DBA’s too) doing without trying to understand or think about the complete picture of what is affected. The task of making changes to an existing database object such as tables, stored procedures,  views etc.

Many times, database objects will have to be modified (altered) at a later time, for a table or view it would be adding new columns or changing the data types of the existing columns. For stored procedures it would be change in logic that needs to be incorporated. There are multiple ways to achieve this, one way is to drop the existing one and create the newer one (most probably for a view or stored procedure), the other way is to alter the existing one. What a user needs to keep in mind is, that when you drop a database object and create the new one, the underlying security permissions get whacked and those users / logins that have been assigned additional permissions to these objects will not have the permissions to carry out their task, they should be reassigned with those permissions on the newly created database.

Hence I feel, it is better to alter the existing one instead of dropping and creating.

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.

– Bru Medishetty

Using DBCC UPDATEUSAGE to correct inaccuracies

Recently a friend of mine asked to help, their SQL Server was not showing correct database free space information even when they have added new data file. As they add new data into their database the previously existing database data files are not getting filled with data, rather the newer data files are getting filled. 

As soon as I heard the issue from him, I knew it was the due to the inaccuracies in the catalog views maintained by the SQL Server. I suggested him to run DBCC UPDATEUSAGE command on his database to correct this inaccuracies. 

In order to show you an example, I simulated the same scenario on my personal server, I added few tables and filled plenty of data into those tables. Later I purged bulk of the data in those tables to simulate the inaccuracies. Below is an example DBCC UPDATEUSAGE command that I ran on one of the tables in my database.  

Note that I used the database name ‘LearnSQLWithBru‘ and the table ‘transaction_history‘ in the above example. 

The DBCC command can be run on a database to correct inaccuracies of all objects in that database or you can also correct the inaccuracies of a single table by including that table name. If you would like to run the command for a particular database, then you can run the following command..

DBCC UPDATEUSAGE ('DATABASENAME')

You can also run the below command to correct the inaccuracies for the current database.

DBCC UPDATEUSAGE (0)

Do you like this site? Like our FB page @ Facebook.com\LearnSQLWithBru so that, you know when there is a new blog post.

– Bru Medishetty