Anybody ever tried to search in ntext or text fields on MS SQL Server?
Common experience is to fail.

Solution: cast your search-term to text type, and try again.

Example, using EA-Database:
SELECT * FROM t_xref x
WHERE x.Description LIKE CAST(‘%GUID={761F0C9E-92E4-42d1-8F0A-D3740A2BFF60}%’ AS TEXT)

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Im ersten Teil „Business Solutions entwickeln mit OCF“ wurde beschrieben, wie einfach man zu einem fertigen Grundgerüst für eine Business Solution kommt und wie man mit Hilfe des Entity Wizard alle benötigten Klassen für einen neuen Businessobjekttyp bekommt.

Die konkrete Implementierung einer beispielhaften Businesslogik ist das Thema dieses Artikels. Mit OCF lässt sich jede Art von Businesslogik umsetzen, jedoch wird die Umsetzung von Anwendungen für den Verwaltungssektor besonders unterstützt. Im letzten Artikel wurde schon kurz beschrieben, welche Entity Typen der Wizard anbietet. Businessobject, BaseDocument und Businesscase sind Typen, die in eGov-Fachanwendungen sehr häufig vorkommen. Businessobject ist das Basisobjekt eines jeden Geschäftsobjektes, enthält u.a. ein Property Identificationstring zur Darstellung der Aktenzahl bzw. Geschäftszahl. BaseDocument und Businesscase (Geschäftsfall) sind Ableitungen.

Im Beispiel werden 2 Entities erzeugt: File (Akt) und Document. File wird auf Basis des Entity Typs „Archive Object“ erzeugt, Document mit „Base Document“. Document erhält zusätzlich noch einen Foreign Key, der auf „File“ verweist.

clip_image002

clip_image004Damit erhält man alle benötigten Klassen.

Im Design Modus des LinqToSql Mapping Files „Entities.dbml“ fügt man jetzt manuell eine Association zwischen „File“ und „Document“ ein. Damit wird „File“, also der „Akt“, zum Container für Dokumente. Ein typischer Use Case im Verwaltungsbereich.

clip_image006

Als nächstes folgen ein paar notwendige Anpassungen. Der DataContract „File“ muss um ein Property „Documents“ erweitert werden.

image

Die Klasse “FileTranslator”, die das Business Entity „File“ in den DataContract „File“ übersetzt, muss ebenfalls angepasst werden, damit etwa beim Abfragen eines Aktes die verlinkten Dokumente gleich mitgeliefert werden.

image

Damit sind die Vorbereitungen fertig und man kann die Service Methoden implementieren, beispielhaft die Methoden „CreateFile“, „CreateDocument“ und „GetFileByID“.

Dazu öffnet man das Interface „IBusinessService“ im Contracts-Projekt und ergänzt die Methoden.

image

Die Implementierung des ServiceContracts könnte so aussehen:

image

Damit ist die Implementierung der Businesslogik fertig. Nach dem Update der Service Referenz im Client-Projekt, kann man auf die Service Methoden zugreifen und ein kleines Testprogramm schreiben.

image

Damit hat man bereits das Grundgerüst einer „ELAK konformen Fachanwendung“. Eine interessante Erweiterung des Beispiels wäre die Anbindung an den Dms Service Ocf|Dms. Jedes Document Objekt wäre dann mit einem Content verlinkt.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

This is a very simple scenario, but is taken from a very complex one.
A Customer may have more than 1 address, some may have none. You only want each customer to appear only once. So what can you do?

SELECT C.Name, A.Address
FROM Customer AS C
OUTER APPLY (SELECT TOP 1 *
FROM Addresses
WHERE CID = C.ID) AS A

Note, that this will never work on SQL CE, but on SQL Server 2005 or 2008! And it’s not part of the ANSI standard!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg
SQL Server Management Studio
In some cases the user might install the SQL Server Express Edition, before a “real” SQL Server (Developer Edition).
This can result in a basic version of Management Studio.
Keep in mind, that with SSMSE (e = Express), you cannot manage Analysis Services, Integration Services, or Reporting Services.
The more, you cannot update the full-text catalog by using SSMSE and it does not support scheduling administrative tasks by using SQL Server Agent.
If you installed a Developer Edition of a SQL Server on your system, you also cannot upgrade the basic version of SSMEE. Only possible thing is, to uninstall SQL Express, and do a “Upgrade” with the Developer Edition SQL Setup to the full version.
Easiest way to discover SSMSE: try to connect to a SQL server. If your only choice is “database engine”, that it’s express.

In some cases the user might install the SQL Server Express Edition, before a “real” SQL Server (e.g. Developer Edition).
This can result in a basic version of Management Studio.

Keep in mind, that with SSMSE (e = Express), you cannot manage Analysis Services, Integration Services, or Reporting Services.
The more, you cannot update the full-text catalog by using SSMSE and it does not support scheduling administrative tasks by using SQL Server Agent.

If you later install a Developer Edition of a SQL Server on your system, you also cannot upgrade from the basic version SSMSE. Only possible thing is, to uninstall SQL Express, and do a “Upgrade” with the Developer Edition SQL Setup to the full version SSMS.

Easiest way to discover SSMSE: try to connect to a SQL server: if your only choice is “database engine”, that’s express .

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

There are a lot of scripts out there promising to create insert scripts. You pass in the name of the table, and the scripts create an insert statement for each record contained. Only problem they have: the more columns there are, the greater the chance of lines being cut off in the middle.
The only working & free solution I found up to now is called SSMS Tools. You can get it here: LINK.
It integrates into SQL Server Management Studio and offers a couple of functions. The most important: the creation of insert scripts, based on the result of any sql statement.

This is standard functionality in Oracle clients for years now. So MS, please tell me, why this wasn’t implemented into SQL Server 2008?

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

 

Gestern in Wien tummelten sich über 1000 Personen auf den Big Days! Auch in der Surface Community Lounge war vor allem in den Pausen zwischen den Vorträgen einiges los. In Wien war auch der verantwortliche Entwickler der Big>Days Surface Community App mit dabei– Oliver Lampl  – der im folgenden Bild gemeinsam mit Rolf Mistelbacher von Microsoft zu sehen ist.

Big Days 2010 Vienna 022 

Während der Vorträge ist traditionellerweise an den Ständen der Aussteller wenig los, deswegen sucht unser SQL-Server Experte Andreas Bruckner nach Teilnehmern, die in diesem Bereich von LieberLieber Unterstützung brauchen könnten ;-)

Big Days 2010 Vienna 030

Wir freuen uns jedenfalls schon auf morgen – Linz ist die letzte Station der diesjährigen Big>Days ! – und auf viele interessante Gespräche!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

How to use an Update Cursor on MS SQL Server.
Requirements: If the update-table does not have a Primary Key, the cursor is read-only. So I advise to create at least a temporary Primary Key, and delete it afterwards.

Usage:

DECLARE curs as CURSOR
FOR SELECT * FROM t_image
FOR UPDATE

OPEN curs
FETCH curs INTO @lastValue

WHILE (@@FETCH_STATUS = 0) BEGIN

UPDATE [t_image]
SET [CALC_VALUE] = @lastValue
WHERE current of curs

FETCH curs INTO @lastValue
END

CLOSE calc
DEALLOCATE calc

if you replace “WHERE current of curs” by any “WHERE x = y” statement, it would decrease performance dramtically.

During a test with 80000 records, execution time without update cursor takes 20 minutes. Using an update cursor speeds up to a total time of 20 seconds!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg