T-SQL Removing DB constraints

Quick post, aide-memoire, for disabling and then re-instating database contraints in MS-SQL.

EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"

EXEC sp_MSforeachtable @command1="PRINT '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"
Advertisements

Windows PC not auto-booting?

Since I installed the “Windows 10 Fall Creators Update”, build 16299, the desktop has stopped auto-starting, to it’s BIOS configured schedule. It’s scheduled for a 5:01am start, but every morning I’ve come into the room, since the update, it’s sitting there switched off.

A couple of Google’s later and here’s the answer, well I hope it is as I haven’t verified it yet, something for tomorrow morning. So the suggestion is to disable Windows “fast startup” mode, details on doing that can be found over at TechAdvisor.co.uk, and a more detailed explaination of why is at HowToGeek.com.

29th October 2017: Seems to have resolved the issue.

Cannot synchronise MLAT with Piaware?

Possibly an issue with Pi firmware of 4.9.x, find out your version by using this command

uname -a

If so then issue these commands, the first installs the firmware updater the second the 4.4.50 version of the firmware.

sudo apt-get install rpi-update
sudo rpi-update 52241088c1da59a359110d39c1875cda56496764

If you can’t install the firmware because you have a “custom” kernel then you’ll have to get the latest version of Raspbian and install that, then run the above two commands.

Transact SQL – (Global) script variables

Problem:

When running a SQL script using the command sqlcmd tool if you switch context to another database, by using the “use database” command, then any variables defined before this are lost. A similar thing happens if you use the “go” command to group, or batch, commands in the script.

Solution 1:

Create a temporary table, e.g

CREATE TABLE #GlobalVariables (variableOne varchar(30), variableTwo int)
INSERT INTO #GlobalVariables (variableOne, variableTwo) VALUES ('ABCdef', 222222)

Solution 2:

Use script variables

:setvar variableOne "ABCdef"
:setvar variableTwo 222222

To access these in your SQL code you would do the following:

UPDATE #GlobalVariables SET variableOne = '$(variableOne)', variableTwo = $(variableTwo)

Setting update proxy in Notepad++

Having problems setting, and retaining, the Updater Proxy in the Notepad++ UI?

Then resort to the command line. Open a cmd prompt, with administrator privileges.
At the prompt go to the Notepad++ updater directory, the following works for default installations:

cd C:\Program Files (x86)\Notepad++\updater

From here run this command:

gup -options

This brings up the same dialog as the UI but this time the values you enter will be saved.

gup-options

 

The current identity (IIS APPPOOl\xxxxxxx) does not have write access to…

If you encounter the following error then this may be the fix you’re looking for.


Server Error in ‘/’ Application.


The current identity (IIS APPPOOL\xxxxx) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The current identity (IIS APPPOOL\xxxxx) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The current identity (IIS APPPOOL\xxxxx) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.]
System.Web.HttpRuntime.SetUpCodegenDirectory(CompilationSection compilationSection) +10003412
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +204

[HttpException (0x80004005): The current identity (IIS APPPOOL\xxxxx) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456

 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0


Simply run this code, from the Developer Command prompt: aspnet_regiis -i

Update 3-Jul-17:
On Windows Server 2012 you may need to run this command:

dism /online /enable-feature /featurename:IIS-ASPNET45 /all

 

Reducing wear on your sd-card

One way to increase the lifespan, and presumably, reliability of the sd-card, currently being hammered, in your Pi is to put some of the temporary files into memory.

Add the following to your /etc/fstab

tmpfs /var/log tmpfs nodev,nosuid,size=50M 0 0

If the size isn’t specified then half of the machine’s memory is used.
nodev and nosuid are security options, the suggestion is that these only need setting for public facing machines.

 

8-Jan-2018: If you’re using the lighttpd web server then be aware that it stores files in /var/log, and it doesn’t like them being removed. This will cause the server to fail to start.

Windows – using a local account with the free Windows 10 upgrade?

If so then, for the future, to enable you re-install Windows 10 you will need, before the free offer expires, to register your devices and their Digital Licences with your Microsoft Account.

If you already log into Windows 10 using your Microsoft Account then this has already happened and fresh installs will use that information when it comes to activating your Windows installation.
But if you haven’t then you need to do so ASAP, the free upgrade ends on the 29th July, 2016.

So if you use a local account to login then you need to go to Settings -> Update & security -> Activation and sign in with your Microsoft Account to associate that device and the Digital Licence

If you then want to auto login to Windows, without entering your password, then do the following:

  1. Press the Windows key & R, to bring up the run dialogue
  2. Enter netplwiz, and press enter
  3. Uncheck the “Users must enter a user name and password to use this computer” check box
  4. Click on “Apply”
  5. Enter your Windows account password, ignore the local user name displayed and do not enter the old password
  6. Reboot the PC, and all should be done

Repairing Windows

Just some random jottings on tools to repair Windows, release 10 and maybe 7 and 8 as well.

DISM (Deployment Image Servicing and Management)

Some of the options for this tool are not available depending on Windows version (Enterprise, Professional or Home) and also release.

Sample commands

  • DISM.exe /Online /cleanup-image /scanhealth
  • DISM.exe /Online /Cleanup-image /Restorehealth

SFC (System File Checker)

Tries to repair any file corruption in Windows files.

  • sfc /scannow
  • sfc /verifyonly