Shortcut to run a command line statement within SSMS...

by swjohnson 11/10/2008 9:41:00 AM

I have been doing a lot of data migration and disaster recovery synchronization lately and had a need to run DOS commands quite frequently.  It was a pain to switch from SSMS to the command window or prompt and then run the DOS command or even more interesting the batch files I just exported.  So I found a way to run it from within SSMS.  

Type in your command and make sure to prefix it with two exclamation points !!  Then click the SQLCMD button on the tool bar and then hit Execute (F5) and voila, it runs! 

Switch to blogengine.net for blogging...

by swjohnson 8/16/2008 5:22:00 PM

I have been busy building the business and really haven't had time to blog but now that the family is visiting relatives in Russia, I had some time to convert my blog to blogengine.net.

It was very easy to convert my site and I am really impressed with the features, flexible and documentation for this free application!  Kudos to the team that wrote this!

SQL Internal Viewer...

by swjohnson 7/20/2007 5:14:00 PM

What are you talking about?  No, we aren't talking about looking inside the box.  But have you ever wanted to see what the internals of what SQL is doing.  Well Danny Gould did and this is a little utility he came up with to learn more about the internals and how data is physically allocated, organized and stored. 

Basically he has created a tool that takes all of the information from Shared Global Allocation Map (SGAM), Global Allocation Map (GAM), Index Allocation Map (IAM), Pages, Extents...and so on and creates a graphical depiction of your memory.   Then you can hover over that visualization and it will tell you what that section of memory is allocated to.  Then if you want you can click on it and it will open the Page Viewer which is a hex dump of the header information, data dump, offset table and row interpretation.  From there you can click again and drill down to the various elements that make up a row, including the internal structure and data values.

Check it out!  SQL Internals Viewer

Free Tools from Idera...

by swjohnson 6/29/2007 5:11:00 PM

Idera has some free tools for the taking. 

SQLSafe Freeware Edition:  Idera’s SQLsafe Freeware Edition is free SQL Server database backup and recovery tool based on our award-winning SQLsafe product. SQLsafe Freeware Edition gives you a really high-performance backup and recovery engine, a scriptable interface (command line and XSP) and the ability to backup and compress any size and any number of databases, all for free.

SQLCheck:  SQLcheck is a free performance monitoring tool for SQL Server databases. It provides basic performance information about one SQL Server and runs as a secure screensaver or on demand.

SQLPermissions:  Idera’s SQLpermissions is a freeware tool for copying or moving logins and permissions settings across SQLservers. SQLpermissions automates the time consuming job of configuring logins and permissions on one server to match another by generating a customizable TSQL script to do this for you. SQLpermissions also offers the flexibility to move one login or a group of logins and apply permissions across all databases on the target server, or a single database.

Some new SQL tools...

by swjohnson 6/24/2007 5:11:00 PM

I don't know about you but I am always on the look out for new tools...so it was nice to see two new ones come out. 

1.  RSS Reporter from xSQL software. This is a FREE (for a limited time) utility that creates RSS feeds for your jobs.  The RSS Reported is installed on a server running IIS – any user that has credentials to connect to certain SQL Server instances and view job information can create a profile on the RSS Reporter. The profile for each user contains a list of SQL Server instances, the authentication method, necessary credentials for connecting to each instance, and basic configuration settings. RSS Reporter connects to all the SQL Server instances in the profile and automatically generates a set of predefined RSS Feeds. The user can then subscribe to and read those feeds from any connected device.

2.  Kernel Recovery for SQL by Nucleus Data Recovery.  Kernel Recovery for SQL – data recovery software recovers data from the corrupt Microsoft SQL Server 2000 and 2005. The corrupt, damaged .mdf database files are effectively repaired and data is recovered from them.

Tables, Views, triggers, stored procedures are easily recovered and the damaged unique keys, primary keys and foreign keys are also repaired by Kernel Recovery for SQL - data recovery software. The sql recovery software effectively recovers the deleted records, partly damaged records which get saved in separate batch files. The database rebuilding batch is created automatically by Kernel recovery for SQL with which the database can be easily recreated and the user can again work on it.

I haven't had a chance to play with either one but they do offer some interesting solutions to problems.

Ever wondered what MS does for their SQL Servers???

by swjohnson 6/24/2007 5:06:00 PM

I don't know about you but I have my own hard earned bag of tricks and scripts that I have developed over the years.  Each new SQL Server that I inherit gets these stored procedures, jobs, scripts put on them without fail.  However, I have always wondered what Microsoft does for their SQL Servers...what scripts?, what jobs?, how often?...and the like.  Well, I came across this the other day and my questions had been answered. 

Microsoft AITScripts.zip  (downloads a zip file from from the MS download site)

The scripts in here are from Microsoft and give you a glimpse into what they do on their own DB servers for transaction logs, backups, error log cycling, index defragmentation, and so on. 

As always, I would recommned looking through the code throughly, installing them on a test server first and playing with them there as I can't be responsible for their content and I am sure MS would say the same.   

For me I was suprised to see how similar things were.  We had a lot of the same jobs/tasks but for me it was more interesting to see their code and how they do things. 

Enjoy!

How to automate SQL Installs for your client workstations...

by swjohnson 4/8/2007 4:47:00 PM

Ok so here is my problem. We are rolling out SQL Server 2005 in the coming weeks. The server side will require me to update/upgrade/clean install about 30 SQL Servers and process will be the topic for the next blog entry. But now I must also deploy the SQL Server Management Studio and related tools to over 40 programmers located in 3 different countries and six time zones. Further to that fact, my programmers are a surly bunch and don’t always follow the rules (sound familiar???). So if I give them the disks, they will probably install everything and then call me when it doesn’t work.

So how do I control what they are installing and do this without killing myself in the process? Going around to each desktop is out of the question, I am too busy to do this and I don’t have any lackeys to do it. I don’t know about you but this screams for automation. In SQL 2000, we could create an ISS file and run the install. However, SQL 2005 made that a bit more difficult or did they? Actually, it is quite hidden but still possible. To do a silent install we will create a template.ini file and call the setup application and tell it to use that template.

Ok, so now what do I want them to have? For our world it is pretty basic. They need the SQL Server Management Studio, SQL Server Integration Services, SQL Books Online, SQL Client Network Components, and SQLXML. Nothing fancy here. While we have a few who use MS Reporting Services, I can help them as they are in the same building as me. We don’t use MS Notification Services and I don’t want them to install the developer or personal editions on their local machines.

So now I can start to modify the TEMPLATE.INI file. A shell file is provided by Microsoft and can be found on your install disk #1 on the root. Copy this file to your local to modify. Better safe than sorry. For my purposes, I will be creating two files—one for server installs (SERVER_TEMPLATE.INI) and one for workstation installs (WORKSTATION_TEMPLATE.INI)

Just open the new file (WORKSTATION_TEMPLATE.INI) with Notepad or your favorite text editor. It is pretty well documents but I will just cover the sections that we are installing for our client workstation install.

The first thing we need to modify is the USERNAME and COMPAMYNAME parameters. I have left in Microsoft’s comments about the parameter but in your final file you can easily remove the explanatory text and make a very compact file. However, I would recommend leaving it. My memory isn’t as good as it once was.

[Options]
;--------------------------------------------------------------------
; If USERNAME or COMPANYNAME are not specified, the default
; operating system username and company name values for
; the server are used.
; Note: If names contain spaces, surround the names with quotes.

USERNAME=YourUserNameHere
COMPANYNAME=YourCompanyNameHere

If you put a semi-colon in front of a line, that will remark the line out or tell the system to ignore that line.

Next you need to input your product key by inserting your key in the PIDKEY parameter.

; PIDKEY specifies the Product Identification Key.
; Usage: PIDKEY=ABCDE12345FGHIJ67890KLMNO (This is not an actual
; key value.)
; NOTE: PIDKEY is not required for SQL Server Express Edition.
; NOTE: Do not include "-" in the PIDKEY.
; NOTE: This is not a real key. It is faked; you need to enter your own key here.

PIDKEY=B4H74BJX3P26RX2J8TTBH9RMJ

When entering your key, don’t put in the hyphens (-).

Next, we need to tell it where we want the files installed by specifying the INSTALLSQLDIR. For me the default location works very well 99% of the time.

; INSTALLSQLDIR specifies the location for the instance specific binary files.
; Default location is: %ProgramFiles%\Microsoft SQL Server\
; To use the default path, do not specify the following parameter.
; NOTE: INSTALLSQLDIR is REQUIRED for clustered installations and
; must point to a local drive for which the drive letter exists on
; all nodes in the cluster definition.
; NOTE: If there is a space in a specified path, surround the path with quotes
; and end every path with a '\'.

INSTALLSQLDIR=C:\Program Files\Microsoft SQL Server\

Now we get to the meat of the system. Next we tell the install program what tools and utilities we want installed. This is the ADDLOCAL key.

; ADDLOCAL specifies which components to install. If ADDLOCAL is not
; specified, setup will fail.
; To install all components specify 'ADDLOCAL=ALL' on the command line.
; ADDLOCAL Rules:
; Features are case sensitive.
; To use ADDLOCAL, provide a comma-delimited list with no spaces of the
; features to install.

; Selecting a parent feature only installs the parent feature, not the parent and the child.
; For example: SQL_Engine is the parent feature, SQL_Data_Files is the child feature.
; Installing the child feature automatically installs the parent feature.
; Removing the parent feature removes the parent and all child features. See BOL for
; more information on this topic.

ADDLOCAL=SQL_DTS,Client_Components,Connectivity,SQL_Tools90, SQL_WarehouseDevWorkbench,SQLXML,SQL_Documentation,SQL_BooksOnline

Note: ADDLOCAL should exist all on one line.

The next two sections I added for those rogues who may have already downloaded and installed the Developer or SQL Express Edition. It is our company policy to not do this but since they are administrators on their local machines there is nothing preventing them from that other than the honor code. In your general template file, you probably won’t need these if you are just installing the tools. So you could remark them out.

To use the *AUTOSTART features, specify 1 to start automatically or 0 to
; start manually.
; NOTE: If you decide to start SQL Agent automatically, then SQL is also
; started automatically.
; If *AUTOSTART is not specified on the command line, startup is set
; to manual.

SQLBROWSERAUTOSTART=0
SQLAUTOSTART=0
AGTAUTOSTART=0
ASAUTOSTART=0
RSAUTOSTART=0

;--------------------------------------------------------------------
; To use Mixed mode authentication, use SECURITYMODE=SQL.
; If SECURITYMODE=SQL is not specified, then Windows Authentication only
; will be used by default.
; If you use SQL Authentication, you are REQUIRED to provide a strong
; system administrator (SA) password.
; If you use Windows Authentication, the SA account will be disabled.
; To set SA password specify SAPWD.

; Again these are fake passwords, you should enter your own here.

SECURITYMODE=SQL
SAPWD=98PoB3g$$#

The next section determines how the workstation will communicate with the SQL Server. For us, we prefer to use TCP/IP and NetBIOS disabled.

; The DISABLENETWORKPROTOCOLS switch is used to disable network
; protocol for SQL Server instance.
; Set DISABLENETWORKPROTOCOLS = 0; for Shared Memory= On,
; Named Pipe= On, TCP= On
; Set DISABLENETWORKPROTOCOLS = 1; for Shared Memory= On,
; Named Pipe=Off (Local Only), TCP= Off
; Set DISABLENETWORKPROTOCOLS = 2; for Shared Memory= On,
; Named Pipe=Off (Local Only), TCP= On

; Note: DISABLENETWORKPROTOCOLS if not specified has the
; following defaults.
; Default value for SQL Evaluation/Developer:
;    DISABLENETWORKPROTOCOLS =1
; Default value for Enterprise/Std/Workgroup:
;    DISABLENETWORKPROTOCOLS =2

DISABLENETWORKPROTOCOLS=2

I am sure you are wondering what Shared Memory is all about because it is always on. From Books Online: Shared memory is the simplest protocol to use and has no configurable settings. Because clients using the shared memory protocol can only connect to a SQL Server instance running on the same computer, it is not useful for most database activity.

Now I understand why Microsoft wants the next but I always configure ERRORREPORTING and SQMREPORTING as disabled.

;--------------------------------------------------------------------
; If you enable ERRORREPORTING, SQL Server, SQL Server Agent
; and Analysis Server will be configured to automatically send
; a report to Microsoft if a fatal error occurs. Microsoft uses
; error reports to improve SQL Server functionality, and treats
; all information as confidential.
; To enable error reporting specify ERRORREPORTING=1
; By default ERRORREPORTING=0

ERRORREPORTING=0

;--------------------------------------------------------------------
; If you enable SQMREPORTING, SQL Server Products will be
; configured to automatically send periodic reports to Microsoft
; on feature usage. These reports are used to better understand
; how our customers use our products: which SQL services are installed,
; which features are being used, database deployment, use, and
; maintenance patterns, etc. This will help us determine how to improve
; reliability and how to better target resources in ; future offerings.
; To enable error reporting specify SQMREPORTING=1;
; By default SQMREPORTING=0

SQMREPORTING=0

So that is all we need for our WORKSTATION_TEMPLATE.INI. In its simplest form it would look like:

[Options]
USERNAME=YourUsername
COMPANYNAME=YourCompanyName
PIDKEY=B4H78YOURKEYHERE
INSTALLSQLDIR=C:\Program Files\Microsoft SQL Server\
ADDLOCAL=SQL_DTS,Client_Components,Connectivity,SQL_Tools90, SQL_WarehouseDevWorkbench,SQLXML,SQL_Documentation,SQL_BooksOnline
SQLBROWSERAUTOSTART=0
SQLAUTOSTART=0
AGTAUTOSTART=0
ASAUTOSTART=0
RSAUTOSTART=0
SECURITYMODE=SQL
SAPWD=YourSAPasswordHere
SQLCOLLATION=SQL_Latin1_General_CP1_CI_AS
DISABLENETWORKPROTOCOLS=2
ERRORREPORTING=0
SQMREPORTING=0

NOTE: Again the ADDLOCAL line should be all on one line.

Now that our WORKSTATION_TEMPLATE.INI file is setup, we need to have the SQL installer use it.

To make life easy, I have copied the install disks to the network along with my WORKSTATION_TEMPLATE.INI file which I put in the Disk1 directory.

Now, I map to the network drive and switch to that drive mapping and run the following command from a command line

start /wait setup.exe /qb /settings Y:\2K5\StdEdition\Disk1\workstation_template.ini

Actually, if I really wanted to make life easy, I would create a batch file call install.bat and have it map the network drive, and start the install program.

net use Y: /d
net use Y: \\msw2k3-san1\devarchive$
Y:
cd 2K5\StdEdition\Disk1
start /wait setup.exe /qb /settings Y:\2K5\StdEdition\Disk1\workstation_template.ini

Then, I would have the network admin add that batch file to their network login.bat file that we use each time they login into the network.

SQL Whitepapers...

by swjohnson 3/27/2007 4:42:00 PM

I am working on some documentation and samples for installing SQL Server 2005 silently and during some research I was digging from Whitepapers and found it difficult until I came across this site and they had compiled a good list of them. 

http://www.sqlskills.com/whitepapers.asp

Hope this helps you from having to dig too hard. 

Enjoy!

SQL Server 2005 Service Pack 2 Released...

by swjohnson 2/22/2007 4:31:00 PM

SQL Server SP2 can be downloaded here.  Not too bad at about 280MB to in size.  
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/ servicepacks/sp2.mspx

So what's new in this SP2, well as has been typical of MS lately, they are releasing new features, so make sure you know what you are getting along with the fixes.
http://download.microsoft.com/download/2/B/5/2B5E5D37-9B17-423D-BC8F-B11ECD4195B4/WhatsNewSQL2005SP2.htm

So what's been fixed in this SP2.  Now this is the important stuff...what has been fixed. 
http://support.microsoft.com/?kbid=921896

SQL Server 2005 BOL Update (Feb 19, 2007).  To coincide with the update, the BOL team didn't want to be left out so they also had the Book Online updated.  They have been doing a good job lately getting new materials into BOL!  
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx

Finally, the SQL Server 2005 Best Practices Analyzer (FEB 2007 CTP) was released.  Make to to check it out and see how you stack up.
http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&displaylang=en

Free DBA Tools

by swjohnson 2/19/2007 4:27:00 PM

If you follow this URL http://www.mathomsolutions.com/freestuff.asp?LangID=1, you will see a list of free SQL Server tools for DBA's.  Most of these tools I have used in some form or another and all are quite good.  This just proves that expensive does not always mean quality. 

Please support these individuals as they have given their time and effort to create a quality tool and make sure to respect their license agreement.  Sometimes, a note of encouragement or telling them how their application helped is worth more than money (although money is still nice).  However, most of the time a compliment paid from a fellow DBA, is worth tons!

If you would like your tool listed, just drop me an email with your name, a little bit about your application and where it can be found and I will get it added.

Calendar

<<  December 2008  >>
MoTuWeThFrSaSu
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar