Using the BCP utility that comes with SQL Server 2000/2005 you can quickly export data from one SQL server installation and import it into another. This is described on MSDN.
The tricky thing is to get the command line parameters right, you need to specify the -S argument if you have multiple or named instances of SQL server installed.
Example:
bcp Northwind.dbo.Authors out C:\Temp\DataExport.dat -n -T -S MPDESKTOP\SQL2005
Otherwise you will get stupid errors such as: "NativeError = 18456 .... Login failed for user xxxx" ...
Then the import is pretty simple, you can use Query Analyzer (or SQL server Management Studio) to run this query:
USE Northwind
GO
BULK INSERT Authors
FROM 'G:\Transfer\Tempfiles\DataExport.dat'
WITH (DATAFILETYPE='native');
GO
Monday, February 19, 2007
Friday, February 16, 2007
Class Logging and tracing - approach using custom attributes
If, for debugging purposes, you want to see what is going on in your .Net code, one approach would be to add something like
Log.Debug("FindCustomers -> enter method")
Into each method you are interested in.
Another, more generic and actually pretty cool approach would be to "instrument" your classes using custom attributes.
A sample approach is shown here. (Overlook the repeated and dorky use of the term "spy" :) ).
The drawback is that using the above approach, your classes would have to inherit from a common base class ... but maybe there is a way around that and just use the attribute ...
Log.Debug("FindCustomers -> enter method")
Into each method you are interested in.
Another, more generic and actually pretty cool approach would be to "instrument" your classes using custom attributes.
A sample approach is shown here. (Overlook the repeated and dorky use of the term "spy" :) ).
The drawback is that using the above approach, your classes would have to inherit from a common base class ... but maybe there is a way around that and just use the attribute ...
SQL Server Performance Analysis and Tuning
Came across an interesting post today about using SQL Profiler to analyze performance issues in SQL Server. More can be found here.
Basically the author provides a custom SQL Profiler template and then a set of stored procs to analyze the output of the captured data for long-running stored procs and most cpu-intensive stored procs etc.
Incidentally, the author (Vyas) has a pretty good web site for everything SQL Server related.
Enjoy!
Basically the author provides a custom SQL Profiler template and then a set of stored procs to analyze the output of the captured data for long-running stored procs and most cpu-intensive stored procs etc.
Incidentally, the author (Vyas) has a pretty good web site for everything SQL Server related.
Enjoy!
Thursday, February 15, 2007
HTTP Streaming - interesting alternative to polling
Triggered by a question that came up about how to create a web page that shows data dynamically without user interaction (like a stock ticker, weather conditions etc.), I came across this post that explains HTTP Streaming.
The obvious answer would be to do "polling" having some Javascript timer on the page that makes a periodic XMLHTTPRequest to get data back to the page.
HTTP Streaming is an interesting alternative.
It is also interesting that apparently IE does not send the response to an XMLHTTPRequest back unless the request is complete, so the article also describes a clever way around that.
The main drawbacks I can see are bandwidth and the required resources on the server, basically one open connection (or thread) per connected client.
The obvious answer would be to do "polling" having some Javascript timer on the page that makes a periodic XMLHTTPRequest to get data back to the page.
HTTP Streaming is an interesting alternative.
It is also interesting that apparently IE does not send the response to an XMLHTTPRequest back unless the request is complete, so the article also describes a clever way around that.
The main drawbacks I can see are bandwidth and the required resources on the server, basically one open connection (or thread) per connected client.
Friday, February 9, 2007
VS2005 SP1 - bloat in the Solution (.sln) file
Just ran across this, when adding a new file to a Visual Studio 2005 solution, now the solution gets all these additional entries for each project:
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
And these are not even web site projects, just regular DLLs (Class Library) projects used from a Web Application Project (WAP).
What is going on? Looks like this was a "feature" introduced with SP1. At least I am not the only one seeing this.
Call me old fashioned, but I don't like it ...
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
And these are not even web site projects, just regular DLLs (Class Library) projects used from a Web Application Project (WAP).
What is going on? Looks like this was a "feature" introduced with SP1. At least I am not the only one seeing this.
Call me old fashioned, but I don't like it ...
Wednesday, February 7, 2007
To NOCOUNT or not to NOCOUNT .. that is the question
Well, there has been an ongoing debate whether it is good practice to use "SET NOCOUNT ON" in SQL Server to reduce the network traffic.
I think if you are running UPDATE and DELETE statements or stored procedures where you don't expect any results back or have output parameters that contain the outcome of the stored procedure, it probably makes sense to include it.
There's a post by Jon Galloway that looks at this as well and argues that the RecordsAffected is hardly used anymore in ADO.net and with SqlDataReaders.
So the bottom line is: use SET NOCOUNT ON if you don't need to have the RecordsAffected as part of your business logic.
I think if you are running UPDATE and DELETE statements or stored procedures where you don't expect any results back or have output parameters that contain the outcome of the stored procedure, it probably makes sense to include it.
There's a post by Jon Galloway that looks at this as well and argues that the RecordsAffected is hardly used anymore in ADO.net and with SqlDataReaders.
So the bottom line is: use SET NOCOUNT ON if you don't need to have the RecordsAffected as part of your business logic.
Tuesday, February 6, 2007
ASP.Net Cache - cached items disappearing
Sometimes when working on my local machine, items that I put into the ASP.Net Cache would just seem to disappear immediately from the Cache, defeating the purpose of caching. When hooking in the "CacheItemRemovedCallBack" in the add method, the reason the items were removed from the Cache was "underused".
Basically I was running into the same issue described here. It seems like the Cache was working as expected, it just "thought" that I had not enough memory left to cache any items.
One solution that was suggested on the web is to "disableMemoryCollection" for the cache as described here.
I think that would be acceptable on a developer's machine for debugging, but not for a production server, because again, letting the Cache manage it's own memory seems the better approach here.
The other option is to add the items to the Cache with a "notRemovable" priority. That also seems like asking for trouble, because then ASP.Net is forced to keep stuff in the Cache even if that memory was better used for serving a spike in user requests for instance.
There are a few settings that control the ASP.Net Cache's policies on reclaiming space and purging items settings: http://forums.asp.net/thread/1199949.aspx
Basically I was running into the same issue described here. It seems like the Cache was working as expected, it just "thought" that I had not enough memory left to cache any items.
One solution that was suggested on the web is to "disableMemoryCollection" for the cache as described here.
I think that would be acceptable on a developer's machine for debugging, but not for a production server, because again, letting the Cache manage it's own memory seems the better approach here.
The other option is to add the items to the Cache with a "notRemovable" priority. That also seems like asking for trouble, because then ASP.Net is forced to keep stuff in the Cache even if that memory was better used for serving a spike in user requests for instance.
There are a few settings that control the ASP.Net Cache's policies on reclaiming space and purging items settings: http://forums.asp.net/thread/1199949.aspx
Saturday, February 3, 2007
In search of: Extensible web service framework
I am looking for a good approach to create a web service that is pretty generic and can be extended. Requirements:
- easy to add new functionality
- multiple clients can hit this web service, clients can be on different software versions, new available functionality should not break older clients.
I found this interesting article "A web service as a framework for simplifying development and deployment of business functions". Somewhat against the "true" tenets of designing web service contracts etc., but might fit the bill for what I need.
The input and output parameters of this generic web service are typed datasets, and the business assemblies are loaded using reflection based in a service name given in th request.
The disadvantage is that the functionality is not explicitly described in the web service contract, it needs to be implicitly known by the client and the server (business logic assembly) based on the service name passed in. This keeps the web service interface constant when new functionality needs to be added (versioning is not a problem this way).
- easy to add new functionality
- multiple clients can hit this web service, clients can be on different software versions, new available functionality should not break older clients.
I found this interesting article "A web service as a framework for simplifying development and deployment of business functions". Somewhat against the "true" tenets of designing web service contracts etc., but might fit the bill for what I need.
The input and output parameters of this generic web service are typed datasets, and the business assemblies are loaded using reflection based in a service name given in th request.
The disadvantage is that the functionality is not explicitly described in the web service contract, it needs to be implicitly known by the client and the server (business logic assembly) based on the service name passed in. This keeps the web service interface constant when new functionality needs to be added (versioning is not a problem this way).
Friday, February 2, 2007
Insufficient system resources exist ... what's going on?
So finally today I got my new Seagate Barracuda 320 GB hard drive, put it into a USB 2.0 enclosure and started copying files (I mean thousands of files) onto it. After a while I get the following error "Insufficient system resources exist to complete the requested service." I am running Windows XP Pro, SP2.
Great.... just what I need...
Bad drive?
USB enclosure bad?
So I did some searching, increased my page file size, turned off any background programs, reboot, reboot .. no avail.
I finally found this article by Microsoft "Backup program is unsuccessful when you back up a large system volume" ... I applied the first registry change (PoolUsageMaximum) with a setting of 60 and that did the trick!
I mean how on earth are you supposed to know that there is some system internal kernel memory limit of 160 MB? Well well ... seems to be working fine now.
Great.... just what I need...
Bad drive?
USB enclosure bad?
So I did some searching, increased my page file size, turned off any background programs, reboot, reboot .. no avail.
I finally found this article by Microsoft "Backup program is unsuccessful when you back up a large system volume" ... I applied the first registry change (PoolUsageMaximum) with a setting of 60 and that did the trick!
I mean how on earth are you supposed to know that there is some system internal kernel memory limit of 160 MB? Well well ... seems to be working fine now.
Hello Blog
Hi there,
I am actually creating this blog to keep stuff around that I think I might want to look up later on again.
Well, and maybe something in here will be useful for someone else ...
On that note, let's get started ...
I am actually creating this blog to keep stuff around that I think I might want to look up later on again.
Well, and maybe something in here will be useful for someone else ...
On that note, let's get started ...
Subscribe to:
Posts (Atom)