Posts Tagged ‘Microsoft SQL Server’

Reset Default Database from Command Line in SQL Server

During a recent consolidation exercise I was migrating one database at a time and then taking the old copy offline, unfortunately one of the DBs had (un-knowingly) been my default database and next time I tried to log in I received the dreaded “Cannot open user default database. Login Failed.” message. 

I tried one of the workarounds proffered by Microsoft for this exact problem only to receive exactly the same error message, thankfully I then came across this excellent post on SQL Server Nation which explains the entire issue from start to end and offers a couple of fixes based on your particular scenario. 

In my case it was to execute the sp_defaultdb stored procedure using the OSQL utility, for example…

osql -Sservername -E -dmaster -Q”sp_defaultdb ‘username’,'master’”

Sincere thanks to Brandon Galderisi from SQL Server Nation for the fix.

Be the first to comment - What do you think?  Posted by Ash - 20101212 at 11:40

Categories: Microsoft SQL Server   Tags: , , ,

How to Enable xp_cmdshell in SQL Server

There’s a great little feature of SQL Server that allows you to execute command-line statements, allowing you to run batch files, get directory listings or call executables.  The feature is accessed via the xp_cmdshell Extended Stored Procedure, the syntax is pretty simple and looks like this…

EXEC xp_cmdshell ‘dir *.exe’;
In the wrong hands xp_cmdshell could cause havok, for that reason it is disabled by default and in order to enable it you will need to run the following…
– To allow advanced options to be changed.
EXEC sp_configure ‘show advanced options’, 1
GO
– To update the currently configured value for advanced options.
RECONFIGURE
GO
– To enable the feature.
EXEC sp_configure ‘xp_cmdshell’, 1
GO
– To update the currently configured value for this feature.
RECONFIGURE
GO

Be the first to comment - What do you think?  Posted by Ash - 20101121 at 15:19

Categories: Microsoft SQL Server   Tags: , ,

Installing Business Objects XI R3.1 on Windows Server 2008 R2

Recently I migrated a Business Objects XI Release 2 deployment to XI Release 3.1, a relatively straight-forward process but as always there are a few gremlins to avoid.  Unfortunately the final playbook I used had too many sensitive details in it but during my trial-run I did make a few notes that served me well as a rough workflow and I thought it might be worth sharing.

It’s a mix of steps to take with a few hints thrown in, for the trial run I built a one-box solution (DB+BO on the same server) which isn’t necesarily good practice but works well as development box.  Please bear in mind that this is by no means exhaustive and there’s no substitute for reading the Business Objects documentation…

  • Create a domain user under which you Business Objects services will run.
  • Install SQL Server 2008 R2 Express (you could use MySQL I but I prefer MSSQL).
  • Ensure that SQL Server runs under the domain account (can be done during setup or afterwards).
  • Create databases for the CMS + Audit DBs, create a user that you will use to authenticate with.
  • Install any necessary ODBC drivers.
  • Open Windows Firewall and allow inbound traffic on port 8080 (for Tomcat).
  • Setup CMS + Audit ODBC Sources using c:\windows\sysWOW64\odbcad32.exe
    (see: 32-Bit ODBC Drivers in Windows Server 2008 R2)
  • Configure IIS to Enable 32-bit Applications + .NET Application Pool = Classic
  • Install Business Objects (everything but MySQL).
  • Open CCM, stop services and set SIA + Apache to run under domain account.
  • Grant permissions on C:\Program Files (x86)\Business Objects to domain account.
  • Restart services.
  • Click “Update Objects” button in CCM (this solved an issue where some Authentication options were unavailable in the CMC).
  • Log in CMC, configure AD Authentication - it’s best to follow the Windows AD SSO NTLM instructions in Business Objects Documentation.
  • Run Import Wizard (I may post some tips later on but it’s quite straight-forward).
  • On Windows 7 PCs go to Control Panel  >> Java >> Advanced >> Security and tick “Enable Mixed Mode (run with protection)” – this solved an issue for WebI users.
  • Set user input locale correctly (I’m in the UK and I had to do this on the client for each user).

I hope that helped, if you have any questions please leave a comment and I’ll see if I can expand on the above.

1 comment - What do you think?  Posted by Ash - 20101111 at 21:22

Categories: Business Objects   Tags: , , , , , , , ,

Register an Extended Stored Procedure in SQL Server 2008 R2

Aside from those integrated into SQL Server (e.g. xp_cmdshell) it’s not often I come across the need to use Extended Stored Procedures but an application I installed recently required that I add their custom procedure to the SQL Server housing the application data.  Having been years since I had last added one it took a little figuring out since I would’ve expected to find it in Management Studio under “Server Objects” or “Management” but it’s somewhere entirely different. 

To add/register an Extended Stored Procedure you’ll need to right-click on…

Databases >> System Databases >> master >> Programability >> Extended Stored Procedures

…and select “New Extended Stored Procedure”.

Next you’ll have to provide a (this will be the name the procedure is called by) and the path to the DLL, you can browse to the the .dll file by clicking on the elipsis. 

The next step is vital since at the moment the only people able to actually use the Extended Stored Procedure would by sysadmins.  All you have to do to remedy that is click on “Permissions”, click “Search”, type “public” in the text box and click OK as follows…

All you have to do now is tick the “Execute” permission to allow the ‘public’ users of the database (effectively everybody) to be able to use the procedure. 

The completed dialog box should look something like this…

Then click “OK” and all should be well.

2 comments - What do you think?  Posted by Ash - 20101109 at 21:09

Categories: Microsoft SQL Server   Tags: , , , , , ,

SQLBits 7 – Saturday Conference Rundown

Starting my third day at SQLBits with a hat-trick of talks on technologies I’m unfamiliar with was a bit of a head-bender but an enjoyable one nonetheless. The first talk I chose was a great overview of how to use completely free tools (SQL Server Express 2008 R2, among others) with completely free spacial data (Ordnance Survey’s Open Data) to create spatial reports in Reporting Services. Since it’s not an area I’m working in at the moment I didn’t get any major take-aways but I do have an understanding of what’s possible and how to go about it – if you’re in the same boat you should check out FWTools, Shape2SQL and Grid InQuest.

The second talk was Matt Whitfield‘s ‘CLR Demystified’ and not being a developer I’ll admit that much of it went over my head but I get the basic principles and most importantly I know what’s possible and where I might make use of CLR. The most interesting avenues for me are the ability to write custom aggregate functions and define custom data types – I was also impressed with the opportunity to increase performance in certain text processing / forward log parsing situations.

The next talk I attended was a gentle introduction to PowerShell and James Boother did a good job of showing where it might be useful for admin tasks, in particular the example of purging old backup/log files based on age lit my eyes up. There was also a demo of PowerShell authenticating with Twitter and posting tweets as admin alerts, alas the demo failed but that could well have been a timeout on the Uni’s WiFi network or just plain old demo-gremlins. I must say thou that I still can’t view PowerShell with some sense of disappointment because with all it’s flexibility and power it’s so damned wordy and many of the tasks it performs could be achieved with less code that a good old Bash script.

As with Friday I attended Quest‘s lunchtime session run by Kevin Kline, Ian Kick, Brent Ozar and Buck Woody – they’re some of the most experienced guys in the SQL community and when you get them together they’re funny as he’ll too so I was both entertained and informed in their myth-busting quiz.

My first afternoon talk was Gary Short’s session on NoSQL which predictably sparked a few polite but irate rebuttals from argumentative DBAs but the session itself was an excellent whistle-stop tour of the predominant NoSQL technologies and use cases. I was encouraged to hear from someone experienced in the field that nobody has quite put together all the pieces to hook up BI tools (that traditionally expect relational/dimensional models or OLAP sources) to the NoSQL back-ends, it’s a shame since I might need to do so pretty soon – I guess I’m going to have to get my hands dirty then!

The final talk was from Kevin Kline of Quest who covered SQL Injection, it was an informative talk that gave me pause for thought about a couple ‘best practices’ that I probably ought to harden a little. Kevin recommended a few tools that I’ll definitely be checking out at some point, notably:

And a few handy sites/articles:

Once more it was a great conference and the free day was every bit as good as the paid day, I can honestly say that I walked out of the event already looking forward to the next one.

Be the first to comment - What do you think?  Posted by Ash - 20101003 at 21:08

Categories: Events, Microsoft SQL Server, NoSQL, Open Data, Security   Tags: , , , , , , , , ,

SQLBits 7 – Friday Conference Rundown

Many people only attend the free ‘Community Day’ of SQLBits and I can understand why given the cost (£125) for the Friday sessions but if SQL Server is how you make your living I really do think it’s worth the money.  It’s not even that the Friday sessions are significantly different in content, it’s really just more of the same high level of quality you get on Saturday but when it comes to SQLBits more is definitely better.

It’s always a tough choice picking which sessions to attend so it’s often best to go with speakers you know will be good so despite having spent the entire previous day with Maciej Pilecki in the SQLBits Training Day I made my first session Maciej’s SQL Server Statistics talk.  Despite a few initial technical gremlins the talk went well and gave a few insights into how statistics are used by the query optimiser with the key takeaways being to always keep both AUTO_CREATE_STATISTICS and AUTO_UPDATE_STATISTICS turned on, to consider turning on AUTO_UPDATE_STATISTICS_ASYNC (does not force queries to wait for stats to be updated but subsequent queries will benefit) and to run sp_updatestats after any major updats or to reindex your tables periodically.

My next session was Brent Ozar‘s Virtualisation and SAN talk, this gave me a whole load of questions to go back to my SAN Administrator with as well as a whole load of tests I intend to perform before I deploy my next Data Warehouse on a Hyper-V guest.  One concept that was completely new to me was the Balloon Driver that hypervisors use to encourage Windows to free-up RAM, since SQL Server is a good citizen it can end-up flushing the entire Buffer Pool and wrecking your performance – the solution is to ensure that Dynamic Memory is disabled in the Hyper-V Manager.  Some great related resources can be found at…

The lunchtime sponsor talk I chose was the one from Quest that covered IT Horror Stories, it was a brilliant session with plenty of audience interaction and steered clear of pimping any specific Quest products but instead just showed that the people that work there are experienced, pragmatic and generally just nice guys.  I think this approach is far better than the extended product demos that many software companies tend to give as their lunchtime sessions as they’ll only be of interest if you’re genuinely considering the product and if you’re not they’ll do little to increase brand awareness with a room full of bored people on Twitter of Facebook.

After lunch I went for Buck Woody‘s talk on Business Continuity which provided a few simple paths and the crucial tasks to help get people started on a business-relevant disaster recovery strategy.  I was particularly impressed with one of the central themes of the talk which was (I’m reading between the lines a little) that even if you think it’s ‘not your job’ to put a DR plan in place, it’s likely that as the company’s ‘Data Professional’ people will still look to you in times of failure and if you’ve already done all of the planning you’ll be the guy with a calm head solving the problem and if you’re not that guy – start getting your CV ready.  Despite having heard the name and having read a few of his blog posts over the years I’d never heard Buck speak and he’s great so if you get the chance to see him you definitely should.

Well that wraps-up the day nicely, I’ll be posting Saturday’s round up soon after I’ve written it!

Be the first to comment - What do you think?  Posted by Ash - 20101002 at 18:00

Categories: DBA, Events, Microsoft SQL Server   Tags: , , , , , , , , , , ,

Next Page »