Monday, 19 December 2011

Full Text Stop Lists in VS 2008 GDR (Data dude)

Our dba asked me today how and where to add a stop list definition file to our database project. Turned out the quickest way to figure out where to add these is by using the schema view, under the Storage node as follows...

image

Tuesday, 13 December 2011

Greyed-out object browser properties

Today I came across something a little odd in the .NET object browser control. I was seeing properties of the System.Windows.Forms.BindingSource class, that were greyed out in one Visual Studio 2008 object browser, but not showing in another. Turned out it was down to the Show Hidden Types and Members setting being different between the two Visual Studio 2008 IDEs.

This meant that in one Visual Studio I could see the SortDescriptions property, but in another I could not.

image

Thursday, 8 December 2011

MVC tutorials

A good set of MVC tutorials up here by pluralsight

http://www.asp.net/mvc/pluralsight

Also, during the JavaScript and Ajax demo, the lecturer points out this excellent link for speeding up your web sites

http://developer.yahoo.com/performance/rules.html

image

You can also then use this add on in Firefox to run those rules and evaluate your site

https://addons.mozilla.org/en-US/firefox/addon/yslow/

For JQuery samples and demos have a look at this link

http://jqueryui.com/

Friday, 25 November 2011

GhostDoc configuration

Finally fixed an issue with GhostDoc that's annoyed me for years.

When you document a method that begins with the word SetupXXX then typically a GhostDoc out of the box would give you something rubbish along the lines of "Setups The ". If you add this rule in manually in the Tools, GhostDoc, Configure GhostDoc options, then you can fix this to be a little more grammatically correct.

(P.S. Back in the day John Rayner started GhostDoc top 10, to name and shame places in the code where people had clearly relied on automatic documentation, and this one I think used to come with in the top 3 most of the time).

8clip_image001

Thursday, 17 November 2011

How to route network traffic with two or more network adapters

Use route /? from a command line to discover the answer...

  1. Get the destination ip address from comparing the tcp receive port number from a PROCMON filter on operation begins with TCP, and the name of the process that you're running e.g. chrome.exe
  2. netstat -n | findstr /i "port number here" - this will give you the destination ip address
  3. route print - to get the interface card number
  4. route add destination.ip.address.here MASK 255.255.255.255 default.gateway.ip.here IF interfacecardnumber

e.g.

> route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
         destination^      ^mask      ^gateway     metric^    ^
                                                     Interface^
  If IF is not given, it tries to find the best interface for a given
  gateway.

Your computer might already be using both connections. It really depends on the topology of the networks, and where the various services lie.
If you are on windows and go to the command line and run "route print" you'll see a table that the operating system uses to decide which interface to send packets out on to a given destination IP address.

If you run "netstat -n" it will show open TCP connections on your computer. The left hand column will show the local IP addressed being used. If you see more than one local address used (besides 127.0.0.1) then your computer is probably already using both connections.
There are similar commands on the Mac, but I'm not sure what they are.

What you'd do, I think, is figure out the outbound IP addresses that matter to you what subnet they're routed through. Route those that way and have the default routing set the other way. Obviously you can route ranges of IP addresses. Whichever is easiest to specify is what you'll specify.

Wednesday, 16 November 2011

How to change your MS Exchange password for Android 2.3 (Gingerbread)

Struggled to find this setting today after changing my corporate password, actually ended up finding it here..

Settings, Accounts and Sync, (Select your account from manage accounts section), Account Settings, Incoming Settings (from the Server settings section).

Tuesday, 15 November 2011

Create auto playlists in Windows Media Player

Was looking the other day to find a way to automatically have a play list for recently added tracks to my library in windows media player. Finally discovered this handy little feature that works very much in the same way that outlook rules work in terms of the user interface, for generating dynamic play lists that update every time you open windows media player

image

image

Fixing a corrupt Windows Media Player library

Just followed the steps here to fix up my windows media player library, as it wasn't letting me create auto play lists today.

http://www.hack7mc.com/2009/02/fix-corrupt-windows-media-player.html

Have included the steps below in case the above web site stops running...

Sometimes a Windows Media Player database can become corrupt for any number of reasons. This will obviously also effect Media Center since it runs off the same database for videos and music. Luckily fixing the problem isn’t too difficult.

WMP Library Delete

First thing that needs to be done is to stop the Windows Media Player Network Sharing Service. This service controls media sharing over your network but it also locks the database file so it can’t be deleted by the user. To stop this service enter task manager (crtl+alt+del) and select the services tab. Find “WMPNetworkSvc” in the list then right-click and select “Stop Service”. If you receive a denied error you can also stop the service from the “Services” button at the bottom.

WMP Network Sharing Service

Once the service has been stopped open Windows Explorer and go to “\Users\YOUR USERNAME\AppData\Local\Microsoft\Media Player”. It may be hidden so you won’t be able to see it but you can type it into the address bar to access the location. Alternatively, you can also enable hidden folders to be shown on your pc by going to Control Panel > Folder Options and enabling showing hidden folders.

Show Hidden Folders

Once you’re in the folder, locate the “CurrentDatabase_371.wmdb” file and delete it. If you receive a permission denied error the “WMPNetworksvc” may not have been stopped or you may need to restart your machine and start again.

Once the wmdb file has been deleted, restart Windows Media Player and the database should begin to repopulate. It may take some time to complete depending on the number of files. That should be all there is to fixing your corrupt Windows Media Player database.

Thursday, 10 November 2011

Javascript tutorial

Excellent online javascript tutorial written as a presentation / wizard format in javascript. (Nice)

http://ejohn.org/apps/learn/

Wednesday, 9 November 2011

The case of the shrinking Tesco's product

One on the left is from last week, and this week hey presto 5cm off the diameter, but same barcode, and same price!!! Shocking stuff.

image

Price last week = £1.35

image

Price this week = £1.35

image

and yet you receive less product, and also smaller packaging as well, which I'm sure saves Tesco a bit of money on top!

_____

Had a reply from Tesco today about this...

From: customer.service@tesco.co.uk
Sent: 12 November 2011 15:00
Subject: TES651915NI: Re your recent enquiry

Dear Merrick
Thank you for your recent email.
Having investigated this matter I can confirm that the size of the tortillas has been decreased to meet the Light Choices criteria (calories and points). We were due to increase the price of this product as the cost in production has increased, however as the product was due to be reduced in size, we have left the price at the same amount.
Hopefully this has sufficiently answered your query, but if you do have any further comments then please don't hesitate to contact me.
Kind Regards
Sian Hackwood
Tesco Customer Service

clip_image001

Wednesday, 12 October 2011

Visual Studio Shortcuts

Just found a new short cut in VS 2008 quite by mistake.

Ctrl + /, puts you up here...

clip_image001

And then you get intellisense commands that you can get the visual studio ide to do, e.g. Debug.AttachtoProcess

Nice.

Monday, 10 October 2011

Orange Broadband Speed Issues


24th November 2011...

I'm happy to report that after 3 months of painfully slow broadband speed, our issues have finally been resolved. Unfortunately it's not known exactly what the problem was that caused it in the first place. We either suspect a rogue radio controlled toy in the toy box (which we have now moved away from our router), or a change by BT or Orange at the Epsom exchange perhaps, although BT wholesale swear blind they haven't changed anything this week to make that be the case.

Anyway, should you be an Orange customer, then there really is only one person you should deal with for resolving your broadband issues. His name is Daniel Flint ( on ext 34045 ). If calling from your orange mobile then just use 150, 1, 2, 2, 2 then ask to be transferred to the Broadband Fault Management team, and then onto him. If you're calling in the afternoon after 4pm then deal with Craig Coleman (on ext 32383). After approximately 40 (yes forty calls to Orange), these were the only two people that actually cared about our case, and were the only ones to ring back when they said they would.


----

Further to my original post about PPP server down with Orange live box issues I was having back in 2006 I have found some notes on a web site about how you can fix your router speed issues these days.
After 32 calls to Orange technical help this month, we're finally hopeful that the 4th BT engineer saying that it is our BRAS profile that has been set incorrectly for our 7mb sync speed, and our SNR noise margin being 3.3db where it should be 6db, is probably what is wrong. More about this here - http://www.kitz.co.uk/adsl/lowSNR.htm
P.S. Worth knowing that if you do contact Orange broadband customer service, then you should ask to be put through to the Fault management team in South Yorkshire directly to speak to someone English that actually has the authority to arrange a BT Special Fault Investigation Engineer to be sent to your property.
Doing this on my Orange Livebox appeared to give me a better speed connection.
You will need your username and password.
1.     Switch off your PC
2.     Switch power off to Router for 3 minutes then switch back on
3.     Wait 5 minutes to allow Router time to stabilise
4.     Switch PC back on
5.     Open internet browser
6.     If still unable to access the internet follow steps below:
7.     Log into Router home page
for BT Business supplied equipment type the following in the address line:
BT Business Hub 192.168.1.254
for non BT equipment please refer to your supplier
8.     Click on settings tab
9.     Click on Broadband
10.     Click on link configuration
11.     You will now be able to see your username and password fields
12.     Please change the username details that appear before the @ symbol as follows:
bt_test_user @XXXXXXXXXX  (you must insert underscore _ in the name as shown)
13.     Please leave password field blank unless prompted in which case enter ADSL (upper case)
14.     Scroll to bottom of page and click on save
15.     If prompted for Router password please input if not known click on "forgot password" link
16.     This will connect the router on test details and the internet light will change to green
17.     Repeat from step 7 above and change user name and password back to your own details.

Appendix A - Good speed test sites

http://www.bbc.co.uk/iplayer/diagnostics#results - starting to like this one best now.
http://speedtest.net/ - my most used one
http://speedtester.bt.com/ - this is the official one that BT will recognise you have a fault from.
http://www.uswitch.com/broadband/speedtest/streetstats/ - Find stats from other houses on your street here as well

Appendix B - Good line testing sites

http://tools.ssl128bit.net/Whoosh/LLU.aspx?telephone=0123456789

Appendix C - Useful contacts

08448 738 586 (called from your home land line) to Orange Fault management team in the UK (South Yorkshire) - use these guys to get your BBEU number and progress it with BT Wholelsale (see next contact number)...
https://www.btwholesale.com/ - Faults team on 0800 085 3608 (option 3 wait a long time for phone to be answered though!). You will require your BBEU number (or CBUK number or VPMS number) to get through to them. Also eChat to them available here - https://btwholesale.com/pages/static/echat.html - select the IP/DATA/WBC products link on the right to chat to someone directly.
bring.your.broadband@everythingeverywhere.com - email address for South Yorkshire team that manages Orange broadband

Appendix D - Checking what speed you should be getting

Find your SNR noise margin and your attenuation stats off your broadband router. Type your attenuation into this calculator, http://www.kitz.co.uk/adsl/max_speed_calc.php,  to see what speed you should be entitled to get (on a wired connection to your router that is).
Your SNR margin should be above 6db at least as well, so worth checking that. If it isn't complain to your ISP as they should be able to fix this.

Appendix E - Connecting to BT OpenZone account

Have also discovered that for Orange customers you can connect to the BT OpenZone Wifi network using your orange email username and password.

SQL Server Foreign Key Constraint Issues

Added my responses to this article on SQL Server Central today, as we were having exactly the same issue occurring on SQL Server 2008 SP2...

http://www.sqlservercentral.com/articles/Foreign+Keys+(FK)/75346/

The fix we used, was to simply add the DROP_EXISTING = ON option to the creation of the new Index.

Tuesday, 4 October 2011

How to: Macro for attaching to w3wp.exe

Use the macro below to attach your debugging engine in Visual Studio 2008 to the IIS worker process.

(Note: have updated this to dynamically pick up the Machine name from the System.Environment class.)

    Sub AttachToW3p()

        Try
            Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
            Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
            Dim dbgeng(1) As EnvDTE80.Engine
            dbgeng(0) = trans.Engines.Item("Managed")
            Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, System.Environment.MachineName).Item("w3wp.exe")
            proc2.Attach2(dbgeng)
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try

    End Sub

Thursday, 29 September 2011

How to see all running SQL statements

My colleague Paul McMillan left me with this lovely SQL view that you can install on your database to discover all the currently executing SQL (with the full TSQL statement text, not just a buffer from a dbcc inputbuffer call).

It also gives you a link to click to open the query plan as well

image

 

CREATE VIEW [Current_Running_SQL]

AS

SELECT CASE

WHEN  Requests.sql_handle IS NULL

THEN ' '

ELSE SubString

(

                                          Statements.text,

(Requests.Statement_Start_Offset+2)/2,

(

CASE

WHEN  Requests.Statement_End_Offset = -1

THEN LEN(CONVERT(nvarchar(MAX),Statements.text))*2

ELSE  Requests.Statement_End_Offset

END

-

                                                Requests.Statement_Start_Offset

)

/

                                          2

)

END AS StatementText,

                  QueryPlans.query_plan                                 AS QueryPlan,

                  Statements.Text AS Batch_Text,

Sessions.Session_ID,

Sessions.Login_Name,

Sessions.Host_Name,

Sessions.Program_Name,

Sessions.Client_Interface_Name,

                  Requests.Wait_Time,

                  Requests.Cpu_Time,

                  Requests.Total_Elapsed_Time,

                  Requests.Reads,

                  Requests.Writes,

                  Requests.Logical_Reads,

                  Requests.Row_Count,

                  Requests.Granted_Query_Memory*8/1024            AS Granted_Query_Memory_MB,

LEN(Statements.text) AS Batch_Text_Length,

                  Requests.Statement_Start_Offset/2               AS Statement_Start_Offset,

CASE

WHEN  Requests.Statement_End_Offset = -1

THEN LEN(CONVERT(nvarchar(MAX),Statements.Text))*2

ELSE  Requests.Statement_End_Offset

END

/

                  2                                                                 AS Statement_End_Position,

(

CASE

WHEN  Requests.Statement_End_Offset = -1

THEN LEN(CONVERT(nvarchar(MAX),Statements.text))*2

ELSE  Requests.Statement_End_Offset

END

-

                        Requests.Statement_Start_Offset

)

/

                  2                                                                 AS Statement_Text_Length

FROM sys.dm_exec_sessions Sessions

INNER JOIN sys.dm_exec_requests                      Requests

ON Sessions.session_id                             = Requests.Session_ID

CROSS APPLY sys.dm_exec_sql_text(sql_handle)    Statements

CROSS APPLY sys.dm_exec_query_plan(plan_handle) QueryPlans

WHERE Sessions.Session_ID                             != @@SPID

GO

Thursday, 22 September 2011

Gotcha: Editing tests in Visual Studio 2008 is unresponsive

If you have an issue where by Visual Studio 2008 appears unresponsive during editing the code in a unit test, this could be down to “CMI” = “Code Model Inspection” which involves catching all (yes, *all*) events from the code editing window.  These events are put onto a queue which is polled periodically and then the Test View / Test List Editor is brought up to date.  The default time for this polling is 1.5 sec, but it can be configured from the registry. 

The registry hacks below set this polling interval to one day.  Since I’ve done this, I can edit tests just as smoothly as any other code.

On x86 machines

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\EnterpriseTools\QualityTools]
"CMUnitTestDelay"=dword:05265c00
"EnableCMI"=dword:00000000

For x64 machines

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\EnterpriseTools\QualityTools]
"CMUnitTestDelay"=dword:05265c00
"EnableCMI"=dword:00000000

Tuesday, 20 September 2011

How to shut down windows 8

Spent a little time looking at Windows 8 developer preview and it appears this has been baffling a number of users. Found the answer on a you tube video here in the end

http://www.youtube.com/watch?v=5m6-ExUSFGQ

But knowing me, I wanted a more efficient way of doing this, (apart from the classic Win+D, Alt+F4), so noticed in the comments to this video that you can now use Win+I to get to the settings menu directly, and from there, you'll find a power button...

image

Friday, 16 September 2011

SQL 2008 Database Maintenance plan not working

The other day we had an issue on SQL Server 2008 (10.0.4000) whereby a newly created maintenance plan was failing to execute.

Turned out this was due to the sp_configure value of "allow updates" having been set to 1.

To fix it we simply ran this sql statement and then set up the maintenance plan again...

sp_configure 'allow updates', 0
reconfigure
go

Thursday, 8 September 2011

Outlook Mailbox / Inbox repair tool

Just had to do this again today, after my outlook 2010 wouldn't open, so I thought I would re-blog it here on my new blog just in case I forget the next time.

Found an article on the web that pointed me in the direction of this nifty little tool for MS Office 2010 inboxes.

C:\Program Files (x86)\Microsoft Office\Office14\SCANPST.EXE

Wednesday, 7 September 2011

Checking logical reads of TSQL statements

Use the following statistics statements to check the logical reads and other performance stats when running a SQL Statement.
set statistics io on
set statistics time on

SELECT * FROM MyTable
set statistics io off
set statistics time off

Another trick for comparing equivalent sql statements, is to run them both with the execution plan on, and then compare the relative cost to the batch in the resulting execution plans of each statement.

Thursday, 1 September 2011

Nifty trick for finding SQL table column names

select top 0 * from MyTable

Gets you the column names instead of having to add a where clause e.g. (where 1= 0)

When is a DateTime? not a DateTime

Interesting fact I just discovered about Nullable<DateTime> (i.e. DateTime? objects) today, is that when you type check it against a non nullable version i.e. System.DateTime, then it will be classed as a DateTime type if the nullable DateTime? has a value.

E.g.

image

image

Thursday, 18 August 2011

SQL 2008 Change data capture

Fed up of using triggers to track changes on your data tables? Try using change data capture instead.

"Change data capture provides information about DML changes on a table and a database. By using change data capture, you eliminate expensive techniques such as user triggers, timestamp columns, and join queries."

http://msdn.microsoft.com/en-us/library/cc627397(v=SQL.105).aspx

SQL Server 2008 Filtered Index and xEvents

Just came across these bad boys, that can drastically increase your query performance as well as reduce the over head in the maintenance and storage costs of the index

 

CREATE NONCLUSTERED INDEX FIBillOfMaterialsWithEndDate     ON Production.BillOfMaterials (ComponentID, StartDate)     WHERE EndDate IS NOT NULL ;

For more information on these see here


http://technet.microsoft.com/en-us/library/cc280372.aspx


or here


http://blog.sqlauthority.com/2008/09/01/sql-server-2008-introduction-to-filtered-index-improve-performance-with-filtered-index/


Also just had my eyes opened to this new concept in SQL Server 2008 called xEvents


http://sqlserverpedia.com/blog/sql-server-bloggers/are-my-connections-to-sql-server-using-connection-pooling-correctly/


which can be helpful for performance reasons...


http://msmvps.com/blogs/eladio_rincon/archive/2008/12/07/using-xevents-extended-events-in-sql-server-2008-to-detect-which-queries-are-causing-page-splits.aspx

Thursday, 11 August 2011

VBA Excel Macro for Hyperlinking first column

Use this macro in an excel 2010 spreadsheet to turn the first column of a table into hyperlinks, using the text of the table as a hyperlink.

Sub CreateLinks()
'
' CreateLinks Macro
'
' Keyboard Shortcut: Ctrl+R
'
   
    Dim i As Integer

    'Starting on row 2 because I have a header.
    Range("A2").Select
   
    'move to the final cell in the first column
    ActiveCell.End(xlDown).Select
       
    Do Until ActiveCell.Row = 1
   
        ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
           ActiveCell.Text, TextToDisplay:= _
           ActiveCell.Text, ScreenTip:= _
           "Click here to open Person record in Beacon"
               
        Range("A" & ActiveCell.Row - 1).Select
       
    Loop
   
   
End Sub

Tuesday, 26 July 2011

Monday, 25 July 2011

How to get your unit tests (test project in Visual Studio 2008, a.k.a. MSTest) run multithreaded

 

Add this to the configuration for the test

<TestRunConfiguration ...>

...

<ExecutionThread apartmentState="MTA" />

</TestRunConfiguration>

To check the threading model used, add the following line to your test(s):

[TestMethod]

public void YourTest()

{

System.Diagnostics.Debug.WriteLine(System.Threading.Thread.CurrentThread.GetApartmentState().ToString());

// TODO: Add test logic here

}

http://blogs.msdn.com/b/irenak/archive/2008/02/22/sysk-365-how-to-get-your-unit-tests-test-project-in-visual-studio-2008-a-k-a-mstest-run-multithreaded.aspx

Tuesday, 19 July 2011

How to just send the updated columns via NHibernate

Use the following attribute in the top of the mapping file to ensure your update statements are as succinct as possible

Dynamic-update="true"

This will ensure only those column values that have changed actually exist in the SET clause of the UPDATE statement, which is useful if your tables have triggers on them guarded by the TSQL IF UPDATE(MyColumnName) type checks.

Tuesday, 5 July 2011

Currently executing SQL view

 

Useful system view that you can create to view the exact (FULL) sql statement that's currently running on a sql server. Kind of like an sp_who2 but with the full executing sql statement shown.

image

CREATE VIEW [Current_Running_SQL]
AS
SELECT            CASE
                        WHEN  Requests.sql_handle IS NULL
                        THEN  ' '
                        ELSE  SubString
                                    (
                                          Statements.text,
                                          (Requests.Statement_Start_Offset+2)/2,
                                          (
                                                CASE
                                                      WHEN  Requests.Statement_End_Offset = -1
                                                      THEN      LEN(CONVERT(nvarchar(MAX),Statements.text))*2
                                                      ELSE  Requests.Statement_End_Offset
                                                END
                                                -
                                                Requests.Statement_Start_Offset
                                          )
                                          /
                                          2
                                    )
                  END                                                               AS StatementText,
                  QueryPlans.query_plan                                 AS QueryPlan,
                  Statements.Text                                             AS Batch_Text,
                  Sessions.Session_ID,
                  Sessions.Login_Name,
                  Sessions.Host_Name,
                  Sessions.Program_Name,
                  Sessions.Client_Interface_Name,
                  Requests.Wait_Time,
                  Requests.Cpu_Time,
                  Requests.Total_Elapsed_Time,
                  Requests.Reads,
                  Requests.Writes,
                  Requests.Logical_Reads,
                  Requests.Row_Count,
                  Requests.Granted_Query_Memory*8/1024            AS Granted_Query_Memory_MB,
                  LEN(Statements.text)                                  AS Batch_Text_Length,
                  Requests.Statement_Start_Offset/2               AS Statement_Start_Offset,
                  CASE
                        WHEN  Requests.Statement_End_Offset = -1
                        THEN  LEN(CONVERT(nvarchar(MAX),Statements.Text))*2
                        ELSE  Requests.Statement_End_Offset
                  END    
                  /
                  2                                                                 AS Statement_End_Position,
                  (
                        CASE
                              WHEN  Requests.Statement_End_Offset = -1
                              THEN  LEN(CONVERT(nvarchar(MAX),Statements.text))*2
                              ELSE  Requests.Statement_End_Offset
                        END
                        -
                        Requests.Statement_Start_Offset
                  )
                  /
                  2                                                                 AS Statement_Text_Length
FROM        sys.dm_exec_sessions                      Sessions
INNER JOIN  sys.dm_exec_requests                      Requests
ON                Sessions.session_id                             = Requests.Session_ID
CROSS APPLY sys.dm_exec_sql_text(sql_handle)    Statements
CROSS APPLY sys.dm_exec_query_plan(plan_handle) QueryPlans
WHERE       Sessions.Session_ID                             != @@SPID
GO

Friday, 1 July 2011

Select TOP @recordCount in TSQL

This is how you can limit the results from a table based on a parameter's value in non dynamic TSQL

declare @recordCountint = 100

SELECT TOP (@recordCount)

*

FROM MyTableName

All you have to do is not forget the enclosing brackets around the variable in the SELECT TOP clause and it works! Without these brackets you see the following error...

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '@recordCount'.

Monday, 6 June 2011

Restoring a SQL database with active users

Sometimes it is necessary to restore a database that has users currently active inside it. Use the following SQL in order to achieve this...

USE [master]
GO
ALTER DATABASE [myDatabaseName] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

RESTORE DATABASE [myDatabaseName] FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\myDatabaseName.bak' WITH  FILE = 1,  NOUNLOAD,  REPLACE,  STATS = 10
GO


USE [master]
GO
ALTER DATABASE [myDatabaseName] SET  MULTI_USER WITH ROLLBACK IMMEDIATE
GO

Is XAML / Silverlight no longer?

Window 8 preview, seems to be based largely on HTML5 and JS...

http://www.microsoft.com/presspass/features/2011/jun11/06-01corporatenews.aspx

Increasing WCF performance

Last week a colleague of mine discovered that for each WCF call, there are actually 2 round trips between client and the server going on using wireshark. This can especially be bad where the network latency on your site is also high, as for each request for data, there is the first call to authenticate the user, which then needs a reply back, then the actual call to get the data, which of course comes back as well, hence 4 x the network latency.

There are some solutions to this e.g. using a Secure Token Service, see http://msdn.microsoft.com/en-us/library/ee748498.aspx for more detail.

There is however an alternative to this which could provide better performance from http://www.noemax.com/

Thursday, 26 May 2011

Debugging IIS w3wp.exe process

When debugging  IIS and taking a while to look at your code, you may sometimes get this message

clip_image002

To fix this simply switch off the ping enabled setting in your IIS, application pool, advanced settings

clip_image004

Monday, 23 May 2011

Binding to a constant in XAML WPF

Example...

Add this to your controls namespace declarations

xmlns:MyNameSpace="clr-namespace:MyNameSpace;assembly=MyAssembly"

then use it as follows in your markup

ToolTipService.ShowDuration="{x:Static MyNameSpace:MyClass.MY_CONSTANT}"

Monday, 9 May 2011

Enabling all disabled triggers in SQL Server


select 'ALTER TABLE ' + o.name + ' ENABLE TRIGGER ' + s.name
from sys.objects o
inner join sys.triggers s on s.parent_id = o.object_id
and s.is_disabled = 1

Friday, 25 March 2011

Rebuilding indexes in SQL Server

DBCC SHOWCONTIG ("dbo.TableName") - Check your Scan Density...

DBCC SHOWCONTIG scanning TableName table...
Table: TableName (2099048); index ID: 1, database ID: 5
TABLE level scan performed.
- Pages Scanned................................: 74056
- Extents Scanned..............................: 9259
- Extent Switches..............................: 9258
- Avg. Pages per Extent........................: 8.0
- Scan Density [Best Count:Actual Count].......: 99.98% [9257:9259]
- Logical Scan Fragmentation ..................: 0.01%
- Extent Scan Fragmentation ...................: 1.57%
- Avg. Bytes Free per Page.....................: 45.7
- Avg. Page Density (full).....................: 99.44%
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

Then rebuld if you need

DBCC DBREINDEX ("dbo.TableName")

Tracing deadlocks in SQL Server

http://www.sqlservercentral.com/articles/Performance+Tuning/tracingdeadlocks/1324/
Found that these three dbcc traceon calls worked for us in SQL 2008
DBCC TRACEON (1222, -1)
DBCC TRACEON (3604)
DBCC TRACEON (1204)

Then check the SQL logs to see exactly what is causing the dead lock to occur

Wednesday, 23 March 2011

Yey - I'm now officially contracting

From 4th April I'll be stepping into the world of the contractor for the first time. How exciting is that!

HTML5 video player tutorial

Bypassing Word document password setting

If you ever have a Microsoft Word document that you want the merged version of, but are unable to do this as there is a password set on the document preventing you from accepting all changes, then simply email the document as an attachment to your Google mail (Gmail) account, and view it online. From there you will see Google does the merging for you and you are then able to export off a new version in word document format, with all the changes accepted.

Using Beyond compare with TFS

If you need to remember the settings to set your external tools in visual studio to use beyond compare then follow the steps here under the heading MICROSOFT TEAM FOUNDATION SERVER (TFS)

http://www.scootersoftware.com/support.php?zz=kb_vcs

image

image

image

Diff

  1. In Visual Studio Choose Options from the Tools menu.
  2. Expand Source Control in the treeview.
  3. Click Visual Studio Team Foundation Server in the treeview.
  4. Click the Configure User Tools button.
  5. Click the Add button.
  6. Enter ".*" in the Extension edit.
  7. Choose Compare in the Operation combobox.
  8. Enter the path to BComp.exe in the Command edit.
  9. In the Arguments edit, use:
    %1 %2 /title1=%6 /title2=%7

3-way Merge (v3 Pro)

  1. Follow steps 1-6 above.
  2. Choose Merge in the Operation combobox.
  3. Enter the path to BComp.exe in the Command edit.
  4. In the Arguments edit, use:
    %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9

2-way Merge (v3 Std, v2)

Use the same steps as the 3-way merge above, but use the command line:
%1 %2 /savetarget=%4 /title1=%6 /title2=%7

My first blog post

Hi there. I’ve just been contemplating with the idea of moving my blog from my company to a more personalised blog engine, that’s supported by windows live writer. Looks as if this is the one for me.

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...