Subscribe: Code Samples
http://code.blogdrive.com/index.xml
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
create  database  day  microsoft sqlserver  microsoft  mobile  new  server server  server  smo  sql server  sql  sqlserver  stored 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Code Samples

Code Samples



Code Samples



Last Build Date: Thu, 22 Sep 2011 20:15:03 PDT

Copyright: Copyright 2011.
 



If you liked this blog...

Thu, 22 Sep 2011 10:10:20 GMT

You'll love Sanders Technology - http://www.sanderstechnology.com - which has been the home of all the more recent technical and code related posts.  Mention this blog and receive a free sticker :) (image)



Frameworks or Flameworks?

Fri, 10 Nov 2006 00:30:48 GMT

 

One of the guys at Readify (Andrew Matthews) recently posted to the Tech list referencing a snippet from old posts/emails:

"most code is the expression of desires through the expansion of code (design patterns) with metadata. Name anything that you have written lately that wasn't like that to some extent."

To which Andrew asked:

"If this is true, and we were ever to find a way to represent our desires more precisely/succinctly, what would be left of our day jobs? Could we ever boil our practical work down to JUST coding the business logic and nothing else? What kind of development environment would we need to be able to do that? Would you want to work in that kind of environment?"

I made two replies to this thread, to whit:

"The real question is do you think that business requirements will ever allow us to only code within a sandbox/framework?

I haven't been in a single environment where the business needs haven't pushed the envelope of cost/time/performance, which usually requires custom solutions, or out-of-the-box thinking."

and later..Andrew asked me if I thought it would be possible in the future to code entirely "in-the-box"..

"I doubt it. Frameworks try to cater for a broad spectrum of requirements and functionality, sort of like a blanket solution. Because new technology gets developed almost dynamically (read: very quickly) I doubt it would be possible to keep up with the day to day (or even month to month) demands of more focused business-specific technical requirements.

My view is that emerging technologies make it easier to develop complex solutions faster (RAD) and can remove some of the time consuming burdon associated with more common tasks/functionality/requirements. This has certainly improved dramatically over the past 15 years.

Then there is the real crux of the matter: if it was just a case of writing business workflows, it'd take all the fun out of programming."

What do you think?

(image)

 

(image)



New SQL Utility

Tue, 17 Oct 2006 03:50:11 GMT

Hi,

There is a new SQL utility published on the Microsoft downloads' site:

http://www.microsoft.com/downloads/details.aspx?familyid=16d8c1e9-a6a3-43a2-9ba7-916c6eb5023b&displaylang=en

It allows the scripting of a database which includes both scripting of the schema as well as scripting the data!  Well worth a look as it could be beneficial in a build process or backup.

I've instaleld it but I haven't had time to see how well it works.  I'm curious as to how it works, whether it uses COM or SMO or DMO or some combination.  If you take a look at it, please leave feedback on it or it's uses here on this post.

Until next post,

Rob

Update:
 
Error: [dbo].[tablename], column 'columnname' is of type [UserDefinedDataTy
pe].  This type is currently not supported.
 

Damn!  No support for UDTs!

(Items in Red have been sanitised for your enjoyment)

(image)



IPv6 Readiness Survey

Fri, 25 Aug 2006 07:47:41 GMT

The Internet Society (ISOC-AU) has recently been working on a new
project, funded by DCITA, in a consortium with auDA, AEEMA and
BuildersNet, to examine Australian readiness to implement IPv6.

As part of this exercise, organisational network planning people
(IT/Systems/Network manager or architect), are asked to complete our
Australian IPv6 readiness survey at http://www.ipv6.org.au/.

If you are at all interested in the future of the internet, please take the time to complete the survey.

Regards

Rob

(image)



IPv6: The Second Conference, plus news from ICANN

Sun, 13 Aug 2006 04:47:02 GMT

Hi All,

Forst off a quick spot for the upcoming IPv6 conference to be held in Canberra in early December.  The website (for more information) can be found at:

http://www.isoc-au.org.au/ipv6summit/

Last year the first IPv6 conference was held in Canberra, and was a very useful and important meeting of the minds.  If you have any interest in the Internet (or Internet-enabled technology) this is THE conference for you.  Book now and I'll see you there.

Now, on to other matters.. ICANN News

According to trusted UK Technology site theregister (a favourite of mine for some ten odd years or something approaching that number) apparently the US Government has finally bowed to international pressure to hand over controlling power of root domain names to an international body (ICANN, the Internet Corporation for Assigned Names and Numbers).

http://www.theregister.com/2006/07/27/ntia_icann_meeting/

This has been long awaited and (although technically nothing has yet been done regarding this transition) will hopefully allow for a more balanced approach to domain name administration and to a lesser extend issues surrounding existing copyright legislation.

Lets hope such a move given ICANN more power to be authorative than the policital equivalent, the United Nations.  It can't be stressed enough though, that the current structure of ICANN will need to change significantly so that it is abreast of the current issues and that it wholly represents the true demographics of the Internet, and not just the US and other western countries.

Thats all for now.  Next post will be something more technical - check back soon.

(image)



SMO Uses

Wed, 28 Jun 2006 15:02:31 GMT

A Word from our sponsors: Vista Support Tool---------------------------------------------See if your machine is capable of running the next Microsoft platform:Windows Vista.  The following is a link to a beta utility which will testyour computer's capabilities with a view to supporting Vista's core functionality:http://www.microsoft.com/windowsvista/getready/upgradeadvisor/default.mspxMicrosoft Australia: Tech Ed 2006---------------------------------------------Check it out.. Tech Ed is on, and the site's up:http://www.microsoft.com/australia/technet/events/teched2006/default.aspxMain Feature: Using SMO to generate stored proc script - by your design.----------------------------------------------------------------------------First thing to do: Upgrade to SQL Server 2005.  Install SP1 and then start a new C# (2.0) project.It's so simple to create SQL Server utilities from .Net nowadays, even more so than wit SMO'spredecessor, DMO.  I've written half a dozen little utilities to help with day-to-day operations,like preparing a script containing 24 hours worth of updates to Stored Procedures.Here's how to batch write in T-SQL the syntax of updated Stored Procs.. Read along..You've created a C# console app, say.  Add the appropriate (minimal) .NET Project References (Microsoft.SqlServer.Smo, Microsoft.SqlServer.SmoEnum and Microsoft.SqlServer.ConnectionInfo).In code, add the appropriate using directives as so:using Microsoft.SqlServer.Server;using Microsoft.SqlServer.Management.Smo;using Microsoft.SqlServer.Management.Common;andusing System.Collections.Generic;Now, connecting and so forth is so easy (depending on your setup).  You can simply do this:Server _Server;Database _Database;string server = "server"; _Server = new Server(server);string db = "database";_Database = _Server.Databases[db];This sets up the objects you need - including authentication.You may need additional authentication, but that is outside the scope of this post.Now, lets get to work..Using generics, create storage for all Stored Procs wewant to includeList procedureList = new List();foreach (StoredProcedure sp in _Database.StoredProcedures){if (!sp.IsSystemObject)        {        if (WasCreated(sp))                {                   procedureList.Add(sp);                                    }        }}The WasCreated() function is examined in detail below.Now, create the Scripter objectScripter spr = new Scripter(_Server);//Write the Create Statementsspr.Options.Permissions = true;spr.Options.ScriptDrops = false;spr.Options.FileName = "path and filename";Once the options are set, we can create thescript.  Notice that the Scripter will write outthe output file as an optionstr = spr.Script(procedureList.ToArray());Here is the content of the WasCreated -- usedto determine the age of the Proc.  Note:_ageComparison could be anything, thoughI am using it in the context of days (1 or more)static bool WasCreated(StoredProcedure sp){TimeSpan ts = DateTime.Now - sp.CreateDate;        //Less than a day old        //if (ts.Days < 1)        if (ts.Days < _agecomparison)        {        return true;        }        return false;}It's that easy..-- Now for something completely differentTh[...]



SMO Uses and more

Mon, 22 May 2006 06:34:50 GMT

My Eventual Next Blog Update A Word from our sponsors: Vista Support Tool--------------------------------------------- See if your machine is capable of running the next Microsoft platform:Windows Vista.  The following is a link to a beta utility which will testyour computer's capabilities with a view to supporting Vista's core functionality: http://www.microsoft.com/windowsvista/getready/upgradeadvisor/default.mspx Microsoft Australia: Tech Ed 2006--------------------------------- Check it out.. Tech Ed is on, and the site's up:http://www.microsoft.com/australia/technet/events/teched2006/default.aspx   Main Feature: Using SMO to generate stored proc script - by your design.---------------------------------------------------------------------------- First thing to do: Upgrade to SQL Server 2005.  Install SP1 and then start a new C# (2.0) project. It's so simple to create SQL Server utilities from .Net nowadays, even more so than wit SMO'spredecessor, DMO.  I've written half a dozen little utilities to help with day-to-day operations,like preparing a script containing 24 hours worth of updates to Stored Procedures. Here's how to batch write in T-SQL the syntax of updated Stored Procs.. Read along.. You've created a C# console app, say.  Add the appropriate (minimal) .NET References (Microsoft.SqlServer.Smo, Microsoft.SqlServer.SmoEnum and Microsoft.SqlServer.ConnectionInfo). In code, add the appropriate using directives as so:using Microsoft.SqlServer.Server;using Microsoft.SqlServer.Management.Smo;using Microsoft.SqlServer.Management.Common;andusing System.Collections.Generic; Now, connecting and so forth is so easy (depending on your setup).  You can simply do this: Server _Server;Database _Database; string server = "server"; _Server = new Server(server); string db = "database";_Database = _Server.Databases[db]; This sets up the objects you need - including authentication.You may need additional authentication, but that is outside the scope of this post. Now, lets get to work.. Using generics, create storage for all Stored Procs wewant to include List procedureList = new List(); foreach (StoredProcedure sp in _Database.StoredProcedures){ if (!sp.IsSystemObject)        {         if (WasCreated(sp))                {                    procedureList.Add(sp);                                    }        }} The WasCreated() function is examined in detail below. Now, create the Scripter object Scripter spr = new Scripter(_Server); //Write the Create Statementsspr.Options.Permissions = true;spr.Options.ScriptDrops = false;spr.Options.FileName = "path and filename"; Once the options are set, we can create thescript.  Notice that the Scripter will write outthe output file as an option str = spr.Script(procedureList.ToArray()); Here is the content of the WasCreated -- usedto determine the age of the Proc.  Note:_ageComparison could be anything, thoughI am using it in the context of days (1 or more) static bool WasCreated(StoredProcedure sp){ TimeSpan ts = DateTime.Now - sp.CreateDate;         //Less than a day old        //if (ts.Days < 1)        if (ts.Days < _agecomparison)        {         return true;        }  &nb[...]



SQL Encryption

Sat, 08 Apr 2006 16:02:30 GMT

Hi All,

Lets talk SQL Server 2005.  So, one of the new features is the inclusion of Certificate management.  This, in turn, allows you to selectively encrypt/decrypt within SQL - consolidating CPU use and centralizing your performance into one point.

You'll need to create a Master Key to use certs/keys.  Something to note is that if you detatch or restore a DB with a master key, you'll need to open the master key *t least once* to register the key with SQL Server.

Once you've created a master key, you can create any number of certificates and from them, a number of symmetric or asymmetric keys.  When you've created certs/keys you'll notice them under the Security branch in SQL Managment Studio.  You'll most likely want to grant control to a user or role.

to actually use a key for encryption, you'll want to store the encrypted data in a varbinary column.  Sizing is the key.. make sure that you have enough space to store whatever you encrypt.

You can easily store your encryption/decryption logic in a stored procedure - which can be called by multiple procedures within your data model.  Be careful when using this functionality as it is CPU intensive.

More on this soon..

 

(image)



Merge Subscriptions - SQL Server to SQL Server Mobile

Sat, 28 Jan 2006 08:32:01 GMT

Hi,

 

So I wrote my first SQL Server Mobile based app last month.  It was .. interesting.  GEtting data onto the Pocket PC was the hardest part by far.  I had an existing MS Access Database which I've had and maintained for donkey's years.

First thing I had to do was port it into SQL Server.  This is kind of ironic since I heard from a SQL team source that SQL Mobile is effectively just MS Access anyway (or Jet, depending on your point of view).

So getting the data from SQL Server to Mobile is another trick.  You'll need to do a subscription.  More on that soon..

 

Rob

(image)



Windows Mobile 5.0 & SQL Server Mobile

Tue, 03 Jan 2006 12:36:16 GMT

Hi,

I went out and bought my wife and I both each a HP iPAQ rx1950 last month.  The main motivator was so that I could start working hands on with Windows Mobile 5.0.

My pet project yesterday was to port across an old Access database which I've been using to keep track of our DVD collection.  It was a bit of an interesting ordeal, and I'm sure I'll get to chronical it in this blog thid\s week or next week.  Suffice to say that it wasn't very straightforward.

I'm going to do some investigation within MS to see if there is a better way than I had to implement.  The brief overview is:  I had to export the data to SQL Server.  Then, I created a Publication and a Subscription (and the Subscription has to be configured specifically for consumption by SQL Mobile). 

Then, I had to configure IIS (although later I worked out a way to bypass this unnecessary step).  This was interesting - had to obtain a debug SSL cert, since the replication required SSL/HTTPS.  That was fine.

Then, I had some issues resolving hostnames - one issue was having to set the HOSTS file, the second was removing and resetting Headers in IIS.  Once done, I managed to attempt my first synchronisation. 

I'll cover part two of SQL Mobile Replication tomorrow..

 

R

(image)