Posts

Showing posts from 2010

Formatting c# code in blog entries

Tip from my old friend Håkan http://www.manoli.net/csharpformat/

How get silverlight (4) service to work with windows integrated security

Follow this post (Follow Ogauthier, not christo) http://forums.silverlight.net/forums/p/187247/430038.aspx Remember to disable anonymous and enable windows auth in IIS

SqlCmd in short

To enable SqlCmd in Management Studio, select: Query / SQLCMD Mode Management studio willl replace variables before these are sent to the Sql server :setvar DbName DevDb go create procedure dbo.GetPersonsFromAnotherDb as select * from $(DbName).dbo.Person print '$(DbName)' go /* Procedure will be created like: ALTER procedure [dbo].[GetPersonsFromAnotherDb] as select * from DevDb.dbo.Person print 'DevDb' */ To execute parameterized from sqlcmd.exe file.sql containts the following: print '$(DbName) was used as input' Execute file: sqlcmd -E -S . -i file.sql -v DbName=TstDb Output: TstDb was used as input

Why do I get this message

When MsSql server expresses itself by the following error: "Internal Query Processor Error: The query processor could not produce a query plan" Usually this message is due to some invalid or conflicting settings with the quoted identifier setting. My lack of interest kept me from learning the mechanics about the error. Usually fixed by removing all set quoted identifier - modifiers in your .sql-files then control this globally with your client (like sqlcmd.exe -I).

Regular expressions cheat sheet

http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/

MsSql 2008 full-text limitations

In SQL 2008 fulltext intexes exclude stopwords. The default stoplist can be disabled by using with stoplist off when creating the fulltext index on the table. Another limitation that I cannot seem to get around is that fulltext search function contains only allow wildcard characters at the end. Probably due to the same index limitations as ends-with ( like '%word' ) searches has. See following examples: Will not match "Joel" select * from Person where contains(FirstName,'"*oel*") Will match "Joel" select * from Person where contains(FirstName,'"*Joe*")

How parse mssql geography data

update v set geolocation=geography::Point(Latitude,Longitude,4326) from dataToBeDressed v where latitude is not null

How to write to output window from SSIS package task script (in data flow)

private void DebugPrint(string message) { bool monkey = false; ComponentMetaData.FireInformation(0,null, message, null, 0, ref monkey); }

hashbytes

/* Checksum() isnt very good for detecting data changes. Use hashbytes() instead Example of output from script below: -361975519341300.801789 */ select avg(cast(cast(hsh as bigint) as decimal(25,0))) as truncatedHash from ( select cast(HASHBYTES('SHA1', [StringField1]+ [StringField2]+ [StringField3]) as binary(20)) as hsh FROM dbo.TableToBeInvestigated ) as hashedData