Recent Posts
Categories
Advertisements
SharePoint and other geekoid tidbits
Microsoft SQL Server comes with a command-line tool for comparing data. The tool is named tablediff.exe and you can find it in the following folder:
%ProgramFiles%\Microsoft SQL Server\<version>\COM
However, you need to have installed SQL Server with ‘Replication’ support, so if you can’t find tablediff.exe just re-run the installer and add Replication support.
You use tablediff like this:
tablediff.exe -sourceserver <> -sourcedatabase <> -sourceschema <> -sourcetable <> -destinationserver <> -destinationdatabase <> -destinationschema <> -destinationtable <>
Just replace <> with appropriate values.
When testing SQL Server jobs I often have to schedule a manual job to run. I do this by editing the job, editing the manual schedule, enabling it and setting a time. This is tedious and fiddly and I’ve found that if you schedule it too soon – less than 90 seconds away – it’s likely to not run. I’ve wasted a lot of time either waiting for jobs to complete only to find out that they haven’t started, or twiddling my thumbs waiting 2 or more minutes for a job to start.
So with a bit of help from some forum questions I’ve come up with a script that schedules a job to run in 90 seconds’ time.
USE [master] GO DECLARE @jobName sysname, @scheduleName sysname, @SCHED int, @JOB uniqueidentifier, @start_date int, @run_time int SET @jobName = 'My Job' SET @scheduleName = 'My Manual Schedule' SELECT TOP 1 @JOB = job_id FROM msdb.dbo.sysjobs WHERE [name] = @jobName SELECT @SCHED = js.schedule_id FROM msdb.dbo.sysjobschedules js JOIN msdb.dbo.sysschedules s ON js.schedule_id = s.schedule_id WHERE js.job_id = @JOB AND s.[name] = @scheduleName SELECT @start_date = CONVERT(int, CONVERT(varchar(8), GETDATE(), 112)) SELECT @run_time = CONVERT(int, REPLACE(CONVERT(char(8), CONVERT(varchar(8), DATEADD(s, 90, GETDATE()), 108)), ':', '')) --SELECT @SCHED, @start_date, @run_time EXEC msdb.dbo.sp_update_schedule @schedule_id = @SCHED, @enabled = 1, @active_start_date = @start_date, @active_start_time = @run_time GO
Installing Visual Studio 2005 on Windows 7
To install VS2005 on Windows 7 without using XP Mode:
To install as administrator, right-click the exe (usually setup.exe) and select ‘run as administrator’.
Connecting Visual Studio 2005 to Team Foundation Server 2010
To connect to TFS 2010, install the Forward Compatibility Update for Team Foundation Server 2010.
Connecting Visual Studio 2005 to Team Foundation Server 2012
To connect to TFS 2012, firstly install the TFS 2012 MSSCCI Provider. You will not be able to choose or edit workspaces in VS2005, so using a different version of Visual Studio that’s already connected to TFS 2012 do the following:
Now, launch Visual Studio 2005 and do the following:
There may be some automatic changes to the solution and project files but after that everything should work OK. You won’t be able to navigate source control in VS2005 but you’ll be able to open recent solutions via the Start page.
SharePoint Designer 2007 is pretty flaky and I frequently run into problems where for no logical reason it can’t edit an item. This is usually down to a messed-up cache. I’ve found that simply deleting offending sites from the cache fixes it and with no apparent down-sides – the fact that the sites I work on are on our own LAN probably makes caching less important to me.
However, SP Designer keeps its cache data in more than one place. I can never remember where these are so I created this little batch file that opens up Explorer windows for both cache locations:
explorer "%LOCALAPPDATA%\Microsoft\WebsiteCache" explorer /e,"%APPDATA%\Microsoft\Web Server Extensions\Cache"
Just run that then delete the entries for the site you’re having problems with (make sure SP Designer is closed first).
This took me a while to cobble together from various sources. It’s VBScript that takes either the path of a site or its description (technically, its ‘ServerComment’, but it’s what you see in the ‘Description’ column of IIS Manager or the ‘Description’ box of a site’s properties) and returns its Identifier.
Save this as GetSiteID.vbs:
Function GetServerComment(SiteNumber) Set IISWebSite = GetObject("IIS://localhost/w3svc/" & SiteNumber) GetServerComment = IISWebSite.ServerComment Set IISWebSite = Nothing End Function Function GetPath(SiteNumber) Set IISWebSiteRoot = GetObject("IIS://localhost/w3svc/" & SiteNumber & "/root") GetPath = IISWebSiteRoot.Path Set IISWebSiteRoot = Nothing End Function Function GetSiteIDByDescription(ServerComment) Set IISObj = GetObject("IIS://localhost/w3svc") For Each Web In IISObj If (Web.Class = "IIsWebServer") Then If (GetServerComment(Web.Name) = ServerComment) Then GetSiteIDByDescription = Web.Name End If End If Next Set IISObj = Nothing End Function Function GetSiteIDByPath(Path) Set IISObj = GetObject("IIS://localhost/w3svc") For Each Web In IISObj If (Web.Class = "IIsWebServer") Then If (GetPath(Web.Name) = Path) Then GetSiteIDByPath = Web.Name End If End If Next Set IISObj = Nothing End Function Set colNamedArguments = WScript.Arguments.Named If colNamedArguments.Exists("description") Then returnValue = GetSiteIDByDescription(colNamedArguments("description")) ElseIf colNamedArguments.Exists("d") Then returnValue = GetSiteIDByDescription(colNamedArguments("d")) End If If colNamedArguments.Exists("path") Then returnValue = GetSiteIDByPath(colNamedArguments("path")) ElseIf colNamedArguments.Exists("p") Then returnValue = GetSiteIDByPath(colNamedArguments("p")) End If Set colNamedArguments = Nothing If len(returnValue) > 0 Then WScript.Echo returnValue WScript.Quit returnValue Else WScript.echo "Usage: GetSiteID.vbs [/description:] [/path:]" WScript.Quit -1 End If
You can use this batch file to call the VBScript file if it’s in the same directory:
@Echo off SetLocal Set siteName=mysite.co.uk GetSiteID /description:%siteName% REM If that way doesn't work do it this way: REM cscript GetSiteID.vbs /description:%siteName% Set siteID=%ErrorLevel% REM Now do something with that Identifier Echo The ID of the site named '%siteName%' is %siteID% EndLocal
I expect to use this when I’ve created a site with the Iisweb.vbs script and then need to make further changes to it with Adsutil.vbs.