John Stagich's Blog

Microsoft .Net Developer

March 2010 Quick Hits

clock March 3, 2010 07:34 by author johnstagich
  • Here is way to copy data between tables with the same structure/layout:

Trucate table destination_tablename

Insert Into destination_tablename
Select *  from source_tablename

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SSIS package does not run when you call the SSIS package from a SQL Server Agent job step

clock February 16, 2010 03:46 by author johnstagich

I created a simple SSIS package to copy a table from one database to another.   The source and destination connections used SQL Server authentication.  

When I tried to run the package in an SQL Agent job I received an error message:  [DTS.Pipeline] Error: component "Source - History" (1) failed validation and returned error code 0xC020801C. 

Here was the fix for me.  When I imported the SSIS package to Integration Services, I set the Package Protection Level to “Rely on server storage and roles for access control.”

 

 

These links helped in solving the problem: 
 

http://support.microsoft.com/kb/918760
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.dtsprotectionlevel.aspx
http://www.codeproject.com/KB/aspnet/Schedule__Run__SSIS__DTS.aspx

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Bulk Insert Error with UNC Path: Message 4860

clock February 2, 2010 05:36 by author johnstagich

I tried executing the following Bulk Insert command, having UNC paths, from SQL Server Management Studio running on my laptop and connected to the appropriate database.  I connected using Windows Authentication.

BULK INSERT dbo.Load_itemDetail
FROM '\\server1\Outbound\orditem.txt'
WITH (FORMATFILE = '\\server1\Outbound\FormatFiles\ORDITEMNEW.FMT')

I then received the following error message:

Msg 4860, Level 16, State 1, Line 2 Cannot bulk load. The file "\\server1\Outbound\orditem.txt" does not exist.

When I had our administrator run the bulk insert command from within SQL Server Management Studio running on the same machine as the SQL Server instance, the command worked.

Fix: When running SQL Server Management Studio from a machine other than the machine where the SQL Server instance resides, you need to connect to the server where the database resides using SQL Server authentication.  The SQL Server login account that you use to connect must also have the "bulkadmin" server role assigned to it.  After logging in with SQL Server authentication, I was able to execute the Bulk Insert command without error.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Highlights from Ron Cundiff's Memphis .Net Users Group Meeting 01/28/2010

clock January 29, 2010 02:12 by author johnstagich

1) Content Delivery Network (CDN)

From Scoth Guthrie: Microsoft Ajax CDN (Content Delivery Network) is a service that provides caching support for AJAX libraries (including jQuery and ASP.NET AJAX).  The service is available for free, does not require any registration, and can be used for both commercial and non-commercial purposes.  Using a CDN can significantly improve a website's end-user performance, since it enables browsers to more quickly retrieve and download content. 

Link to CDN site: http://www.asp.net/ajaxlibrary/CDN.ashx

 2) With jQuery, there are two versions minified and full.  Use the full version if you want to debug.

jQuery version 1.4.1

3)  To get intellisense with JQuery you can enter /// <reference path="jquery-1.2.3.js" /> to the start of your script.  For more information, check a James Hart blog entry and a Scott Guthrie blog entry.

4) Firebug is a great tool for debugging web pages!

5) jQuery and AJAX can be used together with Silverlight to build a website.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


January 2010 Quick Hits

clock January 27, 2010 04:09 by author johnstagich
  • From Karl Shifflett: The WPF & Silverlight Designer Team (Cider Team) has just launched a new team blog at http://blogs.msdn.com/wpfsldesigner/default.aspx

  • Link for SQL Server 2008 Top New Features.

  • SQL training videos from SQLShare site that includes videos on SSIS.  Click on links in Tags section to bring up videos by tag name/topics.
     
  • I wanted to change the name of an Microsoft SQL Database, but was unable to due to the inability to get exclusive control of the database.  Below is a query I found on Will Strohl's blog on how to kill processes/sessions on SQL Server for a particular database.  After running the query and killing the processes/sessions that where preventing me from gaining exclusive control of the database, I was able to rename my database.  Thanks Will!

DECLARE @Database NVARCHAR(150);
-- change this to be the name of your database that you want to kill processes/sessions for SELECT @Database = 'MyDatabaseName';
Select @Database = 'MyDatabaseName';
CREATE TABLE #tempProcesses(
 [spid] [int] NOT NULL,
 [ecid] [int] NOT NULL,
 [status] [nvarchar](150) NOT NULL,
 [loginname] [nvarchar](150) NOT NULL,
 [hostname] [nvarchar](150) NULL,
 [blk] [int] NOT NULL,
 [dbname] [nvarchar](150) NULL,
 [cmd] [nvarchar](150) NOT NULL,
 [request_id] [int] NOT NULL);

INSERT INTO #tempProcesses EXEC sp_who;

CREATE TABLE #tempProcesses2([spid] [int] NOT NULL);

INSERT INTO #tempProcesses2
SELECT [spid] FROM #tempProcesses
WHERE [dbname] = @Database;

DROP TABLE #tempProcesses;

DECLARE @ProcessId INT;
DECLARE [cursorProcess] CURSOR FOR SELECT [spid] FROM #tempProcesses2

OPEN [cursorProcess]
FETCH NEXT FROM [cursorProcess] INTO @ProcessId
WHILE @@FETCH_STATUS = 0
BEGIN EXEC('KILL ' + @ProcessId);
FETCH NEXT FROM [cursorProcess] INTO @ProcessId
END

DROP TABLE #tempProcesses2;

CLOSE [cursorProcess];
DEALLOCATE [cursorProcess];

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


December 2009 Quick Hits

clock December 16, 2009 05:06 by author johnstagich
SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY emailHAVING ( COUNT(email) > 1 )

 

You could also use this technique to find rows that occur exactly once:

SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )
 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


November 2009 Quick Hits

clock November 17, 2009 07:06 by author johnstagich

 

  • I was working with an .csv (comma separated variable) file in Excel.  When saving the document, a column that had numeric data, had the leading zero truncated.  That is, the data was entered as 05, but was saved with only the 5.  The reason for this is because Excel sees that data as numeric, and treats it as such, even though I wanted it to be treated as a text field.   The solution to this problem is to format the cells in the column with a Custom Format.  Highlight the column, and press Ctrl+1.  The Format Cells dialog box appears.  In the Number tab, underneath Category:, select Custom.  In the Type: box, enter 00 (or however many digits you would like to keep).  Save the file.

  • Here is a good T-SQL link for formatting dates: http://anubhavg.wordpress.com/2009/06/11/how-to-format-datetime-date-in-sql-server-2005/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Silverlight 3 FireStarter

clock September 18, 2009 06:56 by author johnstagich

Yesterday, I watch quite a bit of the Microsoft Silverlight 3 FireStarter Event.  The videos for this event should be available shortly, but for the time being; here is a link to the slides. 

Presenters included : 

  • Scott Guthrie (Key Note)
  • Tim Heuer (Top Features and Scenarios)
  • Adam Kinney (Expression Blend)
  • Janete Perez (SketchFlow)
  • Marco Matos (Toolkit and Controls)
  • Brad Abrams (Silverlight Example with RIA Services)  Excellent!
  • Karl Shifflett (XAML Power Toys 5 [will be available this Sunday at 7:00 p.m. PST,  go to Karl's blog])  

Some good links:  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Expression Blend: How to add behavior from Microsoft Expression Gallery

clock September 12, 2009 06:11 by author johnstagich

I was working with SketchFlow in Microsoft Exression Blend.  There was a DragDropItem behavior that I wanted to add to my behaviors.  From the Microsoft Expression Blend Help, here is how you go about adding a behavior created by someone else.  Here the link to the information.

To add interactivity to your application without having to write code, you can drag a behavior from the Assets panel onto an object in your application and then set the properties of the behavior. You can also use behaviors that are created by people in the Microsoft Expression Blend community. For example, you can download custom behaviors from the Microsoft Expression Gallery. If you want to use a behavior that was created by someone else, add a reference to the .dll file or project that contains the behavior. This will make the behavior available in the Assets panel.

Note:

Developers can use the new Expression Blend Software Development Kit (SDK) to create custom behaviors. To view the SDK documentation, click Expression Blend SDK User Guide on the Help menu.

To add a behavior that was created by someone else

  1. Add a reference to the .dll file or project that contains the custom behavior.   From the Project Window, right mouse click on the Project to get the project menu, click Add Reference... to add an assembly (.dll or .exe) to your project.

  2. Build your project (CTRL+SHIFT+B or F5).

  3. Open the Assets panel to view the custom behavior in the Behaviors category.

    You can now drag the behavior onto objects in your application.

     

To make a custom behavior always show up in the Assets panel

If you download an assembly that contains multiple behaviors that you think you will use frequently, you can register the assembly to make the behaviors available to any project you create without having to add a reference.

  1. Do one of the following (Note: the documentation registry path says HKEY_CURRENT_USER\Software\...,  I found it in HKEY_LOCAL_MACHINE\Software... [I am running on Vista]): 

    • For a behavior that is written for Microsoft Silverlight, create a registry subkey in \HKEY_CURRENT_USER\Software\Microsoft\Expression\Blend\v3.0\Toolbox\Silverlight\v3.0 that is named the same as the assembly namespace.

    • For a behavior that is written for Windows Presentation Foundation (WPF), create a registry subkey in \HKEY_CURRENT_USER\Software\Microsoft\Expression\Blend\v3.0\Toolbox\WPF\v3.0 that is named the same as the assembly namespace.

  2. In the subkey, create a default string value and set it to the path of your assembly.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


September 2009 Quick Hits

clock September 8, 2009 02:23 by author johnstagich
  • Frank La Vigne has a great link to learning SketchFlow in Microsoft Expresssion Blend.  The tutorial is comprised of videos, documentation, and code.

  • When working with Microsoft Blend 3.0/SketchFlow, the Assests->Styles->SketchStyles were missing.  Here is a link to the fix.  Go to Chuck Hays entry on July 22, 2009.  I had to add two entries into the registry.

  • From Joe Stagner's blog, Telerik has introducted two FREE Team Foundation Server (TFS) contrls.  They are TFS Work Item Manager and TFS project dashboard.  Here is the Telerik link.

  • Microsoft Web Platform "offers a complete ecosystem for building and hosting web sites, services, and applications."  Note: When installing the Silverlight 3 Tools, close the rest of your applications.

  • Here is a great site for Cheat Sheets for Developers.  It is called Refcardz DZone.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Search

Calendar

<<  March 2010  >>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Archive

Tags

Categories


Blogroll

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in