Add db_datareader and db_datawriter roles to a user for a database.

USE [dbname]
GO

/****** Object:  User [domain\user]    Script Date: 05/26/2011 05:37:39 ******/
IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N’domain\user’)
DROP USER [domain\user]
GO

USE [dbname]
GO

/****** Object:  User [domain\user]    Script Date: 05/26/2011 05:37:39 ******/
GO

CREATE USER [domain\user] FOR LOGIN [domain\user] WITH DEFAULT_SCHEMA=[dbo]
GO

EXEC sp_addrolemember N’db_datareader’, N’domain\user’
EXEC sp_addrolemember N’db_datawriter’, N’domain\user’

GO

Advertisement

How to check for the existence/count of a given distinguished property in BizTalk

 System.Convert.ToInt32(xpath(Response_Select_Query,”count(copy xpath from schema and paste here)”));

———————————————-OR———————————————————————————

theStringValue = xpath(inputMessage, “string(//*[local-name()=’MyElementName’])”);

from the following link

http://www.arquitecturadesoftware.org/blogs/joaomartins/archive/2007/04/11/biztalk-check-if-promoted-property-exists-in-context.aspx

And now you can use System.String.IsNullOrEmpty(theStringValue) to check if the value is present.

Power shell profiles

I am doing a lot of power shell lately, and recently discovered the profiles concept, which let’s you keep all your favorite PS scripts organized in a single place and makes them available to you from all your drives, very similar to your dos environmental variables, it certainly saves a lot of time….

As of know my profile includes the following gathered from various posts on the internet…

**Update**: added method for clearing event log and referenced the same while restarting biztalk..

function .CTFSGet-LatestVersion() {

$login=”dev\username,pwd”

$location = get-location

tf.exe get $location /version:T /recursive /force /login:$login

}

function .CClearEventLog() {

Clear-EventLog -LogName Application

}

function .CRestartBizTalk() {

get-service *BizTalkServerApplication*

get-service *BizTalkServerApplication* | foreach-object -process {restart-service $_.Name}

get-service *BizTalkServerApplication*

.CClearEventLog

}

In order to create a new PS profile run the following cmd and later “notepad $profile” to edit the same.

new-item -path $profile -itemtype file -force

Testdriven.net and Adhoc tests.

If you want to quickly test a method, without writing a unit test or creating  a separate conosole app fot testing, this is a must have, get it now!!!!

In the BizTalk world if you are testing an external assembly (map or orchestration) make sure your remove your .net assembly that your testing  from the gac, once the test passes copy that back to gac again, **one of the limitation of visual studio**, lost good 1/2 hr on trying to figure out why the addin was unable to find my method….