Monday, March 28, 2011

Friday, March 18, 2011

Powershell Cannot Execute Files

Error:
File C:\folder\script.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

Fix:

set-executionpolicy remotesigned

Thursday, March 17, 2011

ASPNET State Database

You will need to run the following commands using a db login that has Create Database permission.
(command prompt)

cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

aspnet_regsql -S serverName -U myUser -P p4zz#w0rd -ssadd -sstype c -d MyASPState

where

-S server name
-U user (database server login)
-P user's password
-d database name

Sunday, March 13, 2011

SQL Loop with Temp Table


declare @id int

while exists(select 1 from #ids)
begin
select top 1 @id = id from #ids

--
-- do stuff
--

delete from #ids where id = @id
end

Tuesday, March 8, 2011

Substring and Character Position

String fucntions

declare @name varchar(10) = 'SMITH,JON'

SELECT SUBSTRING(@name, CHARINDEX(',', @name)+1, LEN(@name)) AS Name

Result:

Name
----------
JON