Posts

Trouble extracting xml data when it has different namespaces?

Ignore namespaces! "select @xmlDoc.query('data(/*:authors/*:child/*:id)') as UserID" from blog post  http://maxbarrass.blogspot.se/2008/02/sql-2005-xml-xquery-ignore-namespaces.html

Getting unique table using PowerShell and SQL SMO

When accessing tables property of database in SMO, tables are indexed using name (excluding schema) This is problematic when using different schemas. To access a table using unique name use the following code $instance = $args[0]  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $srv = new-Object Microsoft.SqlServer.Management.Smo.Server($instance) $db=$srv.Databases["ExampleDatabase"] $table = $db.Tables["ExampleTable"] # will get dbo schema, or random?   $table = $db.Tables | Where-Object {$_.Schema -eq "dbo" -and $_.Name -eq "ExampleTable"} #will get your unique table

Mainframe encoding Finland/Sweden

const string IbmEbcdicFinlandSwedenEuro = "IBM01143"; Encoding encoding = Encoding.GetEncoding(IbmEbcdicFinlandSwedenEuro);

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).