Welp – after a long break I’m back… I’ve recently switched over to git as a code repository – so far it’s been pretty good. Actually very similar to SVN or AccuRev.
My problem so far is with the diff — I don’t have the desire or patience to learn VI. I’ve found that I can integrate winmerge into git. The handy instructions are here:
The steps are as follows:
1) Open .gitconfig file. It’s located at your home directory:
2) Add the lines below. Pay attention to the single quotes wrapping the path to winmerge:
tool = winmerge
cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE"
Here’s an example of how to diff your local copy of web.config with the checked in version:
git difftool -y HEAD .\Web.config
I’ve have occasional issues with some reports where the report will timeout running in the app, but the report stored proc returns in less than a second when I run it in SSMS with the same parameters. I realized a while ago that recompiling the stored proc will fix the issue, but today I found an article that explains why this happens (spoiler: it’s because of cached execution plans & parameter sniffing). So here’s the article – it’s a long read, but it might come in handy for you:
For the new year I’ve decided to keep our testing environment more up to date than it has been in the past by restoring the databases from our backup server at the first of the month. One of the problems I’ve run into though is I run out of space on the log drive. I’ve read the articles that say you should never shrink the log but this is a test environment, so I think I’m ok. So to shrink the logs down I do the usual:
- In SSMS right click the DB – go to Tasks->Shrink->Files
- Change the file type to “Log”, make sure “Release unused space” is selected and click “OK”
So that’s worked just fine in the past – it didn’t work this time though. The shrink file dialog would say the log file could be shrunk anywhere between 89% and 99%, but would only shrink about 10% when the process ran. So I ran across this post:
From that I learned that where the head and tail pointers in the log are affects how the unused space can be released. I figured this was my problem, so now how to fix it… It turns out there is a handy way of telling why the log file won’t shrink – you can use a sql query:
select log_reuse_wait_desc from sys.databases where name = 'DBName'
And then using the table on this page:
Something interesting I noticed was the log_reuse_wait_desc value didn’t populate right away in the sys.databases table. For one of my databases I did a log shrink (which didn’t shrink the log that much) and when I looked at the log_reuse_wait_desc value it was “NOTHING”. I then did another log shrink (which did nothing), but when I checked the log_reuse_wait_desc it had changed to “LOG_BACKUP”.
So my steps were:
- Shrink the log file two times in SSMS
- If the file didn’t shrink:
- Check the log_reuse_wait_desc – it was always “LOG_BACKUP”
- Backup the log by:
- right clicking the db – choose Tasks->Back Up
- change “Backup Type” to “Transaction Log”
- choose a temp file as the destination to backup to and hit OK
- Shrink the DB log again – this time it should shrink the specified amount
- Delete the backup file
Something I’ve been wanting for years – the CSS layout grid:
I’ve run into an old problem – I have a stored proc that takes around 82 seconds to run through my web app. However when I run it through SSMS it returns in about 3 seconds. After poking around for a while it appears to be caused by SQL server parameter sniffing. That’s where SQL server caches optimized execution plans based on parameter values – sometimes these plans can be bad… So to fix it you specify “WITH RECOMPILE”:
For some reason I’ve never written an XSLT against a XML file that used namespaces, up to yesterday. I have a bit of a headache too, and here’s what I found (thanks to Michael Kay). A sample of the XML looks like:
<MITS:Identification Type=”market rate apt” xmlns:MITS=”http://my-company.com/namespace”>
I needed to create an XSL value statement to extract the PrimaryID value. The MITS namespace is obviously a made up address, so I declared a MITS namespace in my XSL with a made up address of “www.bla.com”. I couldn’t get the xsl to work no matter what I tried! I was ignorant about how the xsl engine handles namespaces. The namespace actually acts as a constant, so the values have to match in both files! So I had something that translated like <http: //my-company.com/namespace:PrimaryID> and I was searching for <http: //www.bla.com:PrimaryID>. Makes sense now why I couldn’t get the XSL to work.
In case you guys haven’t seen it, 3 Microsoft guys did a Reddit session where they answered questions from anyone. The questions and responses are very interesting – they talk about technologies I’ve never heard about… If you want to check it out, here it is: