Friday, 12 December 2014

SQLBits have announced their dates for 2015.I have been three times and it is an excellent opportunity to learn and meet fellow DBAs and developers.This year it has expanded to FOUR days, two training days featuring industry experts and two technical session days. Saturday as normal is a free day.If your company’s training budget is limited next year then SQLBits offers the best value for money. Tell your boss that you’re giving up a Saturday to go to the free day and he might be sympathetic to pay for one or more of the other days.

Lots of people have submitted talks for the technical sessions and this year I’ve put my hat in the ring as well.I’ve submitted three sessions:A real DBA don’t need a GUI -A Guided Tour of SSMSBeware of the Dark Side - A Tour of Oracle for the SQL DBATaming the Beast - How a DBA can keep Kerberos under control

Thursday, 12 June 2014

Readers of my blog would be pleased to know that I have teamed up with Packt Publishing and we are organizing a Giveaway for you to celebrate the release of my book and two lucky winners stand a chance to win an e-copy of Getting Started with SQL Server 2014 Administration. Keep reading to find out how you can be one of the Lucky Winners.

Wednesday, 7 May 2014

That’s folks you heard it here first. Since the end of 2013 through to April this year I have been working a book called “Getting Started with SQL Server 2014 Administration” the book is pretty much a look at the new features that would interest the DBA working with the latest and greatest version of SQL Server 2014.It got released last week at the end of April/

You can get it from the publisher and all the leading book websites. I haven’t seen it in Waterstones yet but I’m hopeful. The rumors of orderly queue forming out the Waterstone’s in Newport the night before its release had no foundation. Apparently there was just a long queue for the night-club next door.

Thursday, 24 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

SSMS is a fantastic tool but many people and companies have found ways to enhance it to make it even more useful.At the Exeter SQL Saturday I was chatting with David Atkinson of Red Gate software about their add-ons to SSMS.

David told me about an exciting project that Red Gate have started called the SSMS Ecosystem Project. They have created a framework to make it easier for developers and DBAs to develop, share and manage SSMS add-ons.And the best news is that this framework is free.

Once you’ve created your add-in using the framework you can place it on their add-in directory so others can find and try it out. Red Gate are happy for you to use their API to create commercial tools as well as free ones.Red Gate consider this to be a work in progress, they intend to enhance their API and hope to create a distribution platform similar to the Visual Studio gallery where you will be able to discover and share your add-ons.

SQL Treeohttp://www.sqltreeo.com/wp/Enables users to create custom folders for databases, stored procedures, tables, views and user defined functionsThis is not an exhaustive list. I expect there are plenty of other tools available. Let us know if you have a favourite

Wednesday, 23 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

If you have simple queries or functions that you use regularly you can assign them to a function key for quick running in a query window

Microsoft have already added a fewIf you hit Ctrl-1 in a query window it runs sp_whoThe results are displayed in the results window but the query window doesn’t display the query which can be a bit confusing.

You can set your own up atTools ->Options -> Environment -> keyboard -> Query Shortcuts

You’ll see there are already three already listed

Alt-F1 sp_helpCtrl-1 sp_whoCtrl-2 sp_lock

The function key Alt-F1 can be very useful.In a query window type in the name of a system stored procedure such as sp_MSforeachdbNow highlight the word and hit Alt-F1The results window will show information on the stored procedure and also the parameters used by the procedure. Very handy.

As well as complete queries you can add partial statements to a function key. Let me explainAdd the statement “Select top 100 * from” to Ctrl-4

You must restart SSMS before the function key will workNow open query Window

Type in the name of a table in the query window.Now highlight the table name and hit Ctrl-4The partial query will use the highlighted table name and run the full select query.

Tuesday, 22 April 2014

I have just returned from a trip to Washington DC where I was delivering course 2105 – SQL Server 2012 DBA skills upgrade class in an onsite class to one of Learning Tree’s clients. For those of you that don’t know, a Learning Tree onsite is event is when Learning Tree come to you and deliver a course at your site just for you and can even be tailored or customized to your specific requirements. You can follow the link to read more information about onsite events and what they can include.

This spring I will be delivering two public courses that are scheduled to run in the London Education Centre (LEC)

Monday, 21 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

One of the subjects I covered was Registered Servers and the Central Management StudioThese are two features in SSMS that allow you to register your SQL instances with a more meaningful name and then group them into folders such as project name or type.This can make it much easier to find the instances used by a particular project especially for new starters who won’t know the names of all the instances and projects in your company.The CMS can be shared by all of your DBAs or developers so there is one central list of instances and what they are used for.

One additional feature is the ability to run queries against multiple instances. You simply right click on a particular folder and select “New Query”. A new query window will open with a pink footer showing connected (x/x), where x is the number of instances in the folder. Any query run in this window will execute on every instance in that particular folder.If you select the CMS server itself you can run a query on every instance you have registered

A great feature you may think but what if you accidently ran this in a multi server query window?

exec sp_msforeachdb 'drop database [?];'

Since writing my presentation I have come across a DBA team that aren’t allowed to use the CMS because of the danger of accidently running a dangerous multi server query on every instance in the company.

I’ve hunted high and low but can’t find anyway of disabling the multi query option in SSMS so if you are not willing to risk it then the usefulness of the CMS will not be available to your team.

What do other think? Does your company use the CMS?Are the benefits of the CMS worth the risk of someone accidently running a dangerous multi server query?Have you found a way of disabling the multi server query option?

Thursday, 17 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

SQL Server Management Studio will autosave your unsaved query every few minutes so if if your pc crashes you won’t have lost you work. This is a similar idea to what we see in Word and Excel

Any new query will be added to the solution or project that is currently open. If you don’t have a solution open it will get save into a backup folderMy Documents\SQL Server Management Studio\Backup Files\Solution1

Wednesday, 16 April 2014

We don’t have to provide any other parameters for SSMS to be able to create the database

My Question is from where does SQL get the default values when we create a database without any options?We have always assumed that is was from the model database.

Here’s an interesting exercise:

Create an empty database using the command above and make a note of its size and autogrowth values.Compare these to those of the model database. Assuming you have never changed the model database you’ll find they are identical.

Change the initial size and the autogrowth values in the model database to something obviously different.Now create a new database DB2 with the script

createdatabase DB2

Take a look at the size and autogrowth of the new database and compare them to the values you put in the model database. The data file size will probably match but the rest will have taken the original values you saw in the model database.

SSMS hasn’t used the values in the model database which is what we all assumed it would do

Now create a database using the GUIYou will see in the GUI that the new database has taken its values from the model databaseIt seems that SSMS only uses the model database as its template when you use the GUI, you cannot guarantee the values that will be used when using a simple scriptWhich is why its best practice is to include all the parameters when creating database.

Monday, 14 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

A scenarioA DBA creates a new database and by doing so he become the owner of that database.He then leaves the company and his Windows account is deleted.When you try to view the database properties in SQL Server Management Studio you will receive the error “Property Owner is not available”

When SSMS tries to open the database it check the permissions of the owner and because it can no longer find it in Active Directory it aborts the request

You will not be able to view the properties until a new owner is assigned. This is quite simple just issue this command on the database

sp_changedbowner 'sa'

You cannot just create a new Windows user with the same name. The underlying SIDs will not match.

If the owner of the database is a SQL user then it’s not possible to delete that user but SQL Server can’t manage Active Directory so is unaware when an account has been deleted.

Also note that if the owner of an SQL Agent job is deleted that Agent job will not run because, once again, SQL checks the permissions of the owner and can’t find it in AD so will not continue.

To avoid this scenario it is best practice to ensure that all databases and agent jobs are owned by “sa” unless there is a good reason not to.

Thursday, 10 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

You may have come across this error message when using SQL Server Management Studio

It’s new in SSMS 2008.You cannot, by default, make changes to a table that will require it to be dropped and re-created.These changes are Changing data type on existing columnsOr changing allow nulls on existing columnsOr changing order of columns

Wednesday, 9 April 2014

At my presentation on SQL Server Management Studio at SQL Saturday in Exeter I promised to write some articles on Gethyn’s blog about the bits I didn’t manage to cover.

If a SQL instance isn’t responding or you can’t login for some reason then SSMS has a back door called the Dedicated Administrator Connection or DAC.The DAC uses a special reserved scheduler which has one thread for processing requests. This essentially means that SQL Server is keeping a backdoor open just for this purpose.

To login using the DAC you must be a member of the sysadmin server role.By default, for security, you can only use this from the local server, not from a remote connection.You can enable remote connections using the command

sp_configure 'remote admin connections', 1

To use the DAC, in the SSMS connection window prefix the name of the server with “admin:”

You can’t connect using Object Explorer because it only allows one thread so you must use the Query Window Only

Only one use one admin connection at a time can use the DAC so if another DBA tries to connect using the admin option they will get an error

Also, you should only run simple, quick queries using the DAC.

If you are connecting remotely you many need to get firewall ports opened as well, depending on your environment.This will probably be port 1434, but that will vary depending on your configuration.

SQLcmd also supports DAC Sqlcmd – A

Check that you can use the DAC before you need to use it for real and that you have handy whatever admin scripts you require because, remember, you can’t use object explorer to help you diagnose your problem instance.

Monday, 7 April 2014

A couple weeks back was the second SQL Saturday to be held in Exeter. Although I wasn’t speaking this time, my friend, colleague and fellow contributor to this blog, David Postlethwaite was making his full speaking debut delivering a session entitle “Real DBAs Don’t need a GUI” it was a look at all the features of SQL Server Management Studio that you may not know existed. Unfortunately I was poorly on the day of the event and couldn’t make the session, but David did rehearse his talk with me and it went very well. It seems that his audience agreed and everyone seemed to give him positive feedback. It seems that the whole day was pretty successful and hopefully there will be another SQL Saturday in Exeter next year.

It seems David has caught the speaking bug so to speak. He has come back from Exeter and is keen to expand on this experience. He has put together two further talks. One on Oracle for the SQL Server DBA and another one called “Taming the Beast – How a SQL DBA can keep Kerberos under control.” He has submitted these sessions along with his SSMS talk to several SQL Saturdays around Europe.

If you are organising a SQL Saturday event and you have seen that David has submitted a session then maybe, just maybe, you can invite him along and he can show you how to “tame the beast” :D

Following on from David’s talk on SSMS, he was not able to cover everything in the 50 minute slot so he has kindly put together some blog posts covering the material and topics he was not able to get to during his talk. These will be published over the next few weeks, so stay tuned for more SSMS goodness from David P.

Monday, 13 January 2014

This post is written by David Postlethwaite
If you are using SQL Server 2012 you will probably have noticed that the default account for the SQL services has changed from that used in previous versions. With SQL 2005 and 2008 the default account for SQL service and SQL Agent service was “NT Authority\System”. This is one the built in accounts on a Windows machine, managed by the machine and selectable from a dedicated dropdown list
The Network Service account was introduced in Windows 2003 as an alternative to using the LocalSystem account, which has full local system privileges on the local machine, a major security concern.
The Network Service has limited local privileges easing these security concerns but when many services on a machine use the Network Service account it becomes harder to track which service is actually accessing resources and performing actions, because all the services are using the one Network Service account.
Also, this account, by default, has sysadmin permissions on your instance.
Most people change their service accounts to a local or domain account with limited permissions. This introduces another security problem in that this account has a password that could be hacked and used to launch some sort of attack. Changing the password of a service account regularly can be problematic though programs like Secret Server can alleviate this (www.thycotic.com)
To try and resolve some of these problems Windows 2008 R2 and above introduced a new type of account called a virtual account
Virtual accounts emulate creating many unique instances of the Network Service account, so each service runs with its own instance of the Network Service account. These unique instances of Network Service make auditing and tracking much easier.
You won’t find these virtual accounts listed in Local Users and Groups or Active Directory Users, they cannot be created, deleted, or edited and you can’t change their password. They are not in the built in account list and you won’t find them if you browse for an account.
When you install SQL 2012 on Windows Server 2008 R2 or Windows 7 and later you’ll see the services run with virtual service accounts named like: NT Service\MSSQLSERVER or NT Service\MSSQL$<Instance Name>NT Service\SQLSERVERAGENT or NT Service\SQLAGENT$<Instance Name>
If you change your service account and later want to switch back to using the virtual account you have to type the name in yourself since, because it doesn’t really exist anywhere, you can’t use the browse option to find it.
You also don’t know the password so you can’t type that into the appropriate box. If you do it will tell you it’s wrong. But if you leave the password fields blank and click Apply then Windows will apply the correct password for you and give the virtual account “login as a service” permissions.
One drawback of a virtual account is that it only has permissions to the local machine. If your SQL Server requires access to a network share or something on another machine then you will have to revert to a domain account.
But overall, virtual service accounts are a step in the right direction in securing our databases from attack.
More information can be found at http://msdn.microsoft.com/en-us/library/ms143504(v=sql.110).aspx