Wednesday, June 19, 2013

SSIS - Package Failure on Deployment 2008 R2


http://agilebi.com/jwelch/2010/05/13/moving-ssis-packages-with-ado-net-destinations-between-2008-r2-and-2008/

Microsoft.SqlServer.Dts.Pipeline.ComponentVersionMismatchException: The version of component "ADO NET Destination" (257) is not compatible with this version of the DataFlow.  [[The version or pipeline version or both for the specified component is higher than the current version.  This package was probably created on a new version of DTS or the component than is installed on the current PC.]]

Moving SSIS Packages with ADO.NET Destinations Between 2008 R2 and 2008

As noted by Matt Masson from the Integration Services team, not much has changed in SSIS 2008 R2. In fact, R2 is pretty much identical, with the exception of the ADO.NET Destination. So if you are developing packages, you can build them using the 2008 or 2008 R2 version of BIDS, and they can be used in either environment successfully, as long as the package doesn’t have an ADO.NET Destination. If it does, a package developed in the 2008 R2 version of BIDS will give errors when you open on a machine with the 2008 version of SSIS installed. This is because the 2008 version of the ADO.NET Destination doesn’t know what to do with the new property added to the R2 version.
This wouldn’t be a big deal, if you could have side-by-side installs of BIDS 2008 and BIDS 2008 R2, but the install for R2 replaces the 2008 version of BIDS. So, if you need to move packages developed in 2008 R2 to 2008 (a common scenario for me), you have to do a little extra work. There are a few values that need to be removed or changed by directly editing the package XML.
As always, it’s a good idea to make a backup of your package before editing the XML directly.
Open the package in your favorite text or XML editor, and look for the section that contains . Underneath that, you need to locate the tag that relates to your ADO NET Destination (the sample below is easy, since the name is “ADO NET Destination”, but that’s not the typical case (you do give your components meaningful names, right?).
<component id="16" name="ADO NET Destination" componentClassID="{2E42D45B-F83C-400F-8D77-61DDE6A7DF29}" description="Writes to a database using ADO.NET provider." localeId="-1" usesDispositions="true" validateExternalMetadata="True" version="1" pipelineVersion="0" contactInfo="Writes to a database using ADO.NET provider.;Microsoft Corporation; Microsoft SqlServer v10; © 2007 Microsoft Corporation; All Rights Reserved; http://www.microsoft.com/sql/support;1">
  <properties>
    <property id="23" name="TableOrViewName" dataType="System.String" state="default" isArray="false" description="The Destination database table name." typeConverter="" UITypeEditor="Microsoft.DataTransformationServices.Controls.ModalMultilineStringEditor, Microsoft.DataTransformationServices.Controls, Version= 10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" containsID="false" expressionType="Notify">"sample"</property>
    <property id="24" name="BatchSize" dataType="System.Int32" state="default" isArray="false" description="Specify the number of rows per batch. The default is 0 which uses the same size as SSIS internal buffer. " typeConverter="" UITypeEditor="" containsID="false" expressionType="Notify">0</property>
    <property id="25" name="CommandTimeout" dataType="System.Int32" state="default" isArray="false" description="The number of seconds before a command times out. A value of 0 indicates infinite time-out. " typeConverter="" UITypeEditor="" containsID="false" expressionType="Notify">30</property>
    <property id="26" name="UseBulkInsertWhenPossible" dataType="System.Boolean" state="default" isArray="false" description="Specifies whether to use the SqlBulkCopy interface to improve the performance of bulk insert operations. Only certain providers support this interface." typeConverter="" UITypeEditor="" containsID="false" expressionType="Notify">true</property>
    <property id="27" name="UserComponentTypeName" dataType="System.String" state="default" isArray="false" description="" typeConverter="" UITypeEditor="" containsID="false" expressionType="None">Microsoft.SqlServer.Dts.Pipeline.ADONETDestination, Microsoft.SqlServer.ADONETDest, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91</property>
  </properties>

Once you’ve located the right tag, you need to make two changes:
One, change the version=”1” attribute in the tag to version=”0”.
<component id="16"
           name="ADO NET Destination"
           componentClassID="{2E42D45B-F83C-400F-8D77-61DDE6A7DF29}"
           description="Writes to a database using ADO.NET provider."
           localeId="-1"
           usesDispositions="true"
           validateExternalMetadata="True"
           version="0"
           pipelineVersion="0"
           contactInfo="Writes to a database using ADO.NET provider.;Microsoft Corporation; Microsoft SqlServer v10; © 2007 Microsoft Corporation; All Rights Reserved; http://www.microsoft.com/sql/support;1">
Second, remove the entire element. You can comment it out, as shown below, or just delete it.
< property id="26" name="UseBulkInsertWhenPossible" dataType="System.Boolean" state="default" isArray="false" description="Specifies whether to use the SqlBulkCopy interface to improve the performance of bulk insert operations. Only certain providers support this interface." typeConverter="" UITypeEditor="" containsID="false" expressionType="Notify">true
 
 
 
 
If you have a lot of packages to move back and forth, you probably don’t want to hand edit this each time. I wrote a little application that will process a folder of .dtsx files, and strip the 2008 R2 information out. This is done using an XSLT transform (available in the source code). The application and source are available to download from my SkyDrive.

Wednesday, May 22, 2013

SQL Server Job Information

SELECT
    name   
,    enabled   
,    description   
,    suser_sname(owner_sid)
,    CAST (date_created AS DATE)
,    CAST (date_modified AS DATE)    
,    version_number
FROM msdb.dbo.sysjobs;

Wednesday, May 1, 2013

IIS FTP User Isolation

https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/31c2427c-c0a5-49fa-9e03-823f34fba3e8.mspx?mfr=true

Creating a New FTP Site with Isolate Users Mode (IIS 6.0)

Isolate users mode authenticates users against local or domain accounts before they can access the home directory that matches their username. All user home directories are in a directory structure under a single FTP root directory where each user is placed and restricted to their home directory. Users are not permitted to navigate out of their home directory. If users need access to dedicated shared folders, you can also establish a virtual root. This mode does not authenticate against Active Directory directory service.
Important   You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /user:Administrative_AccountName "mmc %systemroot%\system32\inetsrv\iis.msc".

To create a new FTP site with Isolate users mode

1.In IIS Manager, click the local computer, right-click the FTP Sites folder, point to New, and then click FTP Site.
2.In Welcome to the FTP Site Creation Wizard, click Next.
3.In FTP Site Description, type a description for the FTP site, and then click Next.
4.In IP Address and Port Settings, type an IP address and port number, and then click Next.
5.In FTP User Isolation, click Isolate users, and then click Next.
6.Follow the directions in the FTP Site Creation Wizard.
7.Type or browse to the FTP site home directory, and then click Next.
8.Enable the Read and Write permissions as appropriate, and then click Next, and click Finish.

http://technet.microsoft.com/en-us/library/bb878070.aspx

Q. I am trying to understand the user isolation mode in the Microsoft FTP Server that is included with IIS 6. I do not understand what folders I need to configure as all I get is "User Home Directory Inaccessible" when I try to log onto my FTP site. Can you help?
A. User isolation was added to Microsoft FTP Server with version 6.0 of IIS. This means that user isolation is available on the Windows Server 2003 family only. Future versions will also support this feature.
There are 3 different options for User Isolation when creating an FTP site. These settings can only be set when you are creating a new FTP site and if you want to change the mode you will need to delete the existing FTP site and create a new site, unless you write a script to edit the IIS configuration database.
The three user isolation modes available with IIS 6 are:
Do not isolate users (default option) Users can access the FTP home directory of other users.
Isolate Users Users must be assigned an FTP home directory within the root of the FTP site.
Isolate Users using Active Directory Users must be assigned an FTP home directory that is configured using their Active Directory user account.
Do not isolate users
The default option of "do not isolate users" means that any user that logs onto the FTP site can access any folder on the FTP site (as long as their User Account has the correct NTFS permissions to access the folder). It also means that if a user logs in and there is a folder with the same name as their User Account in the Home Directory of the FTP site then they will be automatically placed into that directory. The user in this case can use an FTP command "CWD /" to move to the root of the FTP site. This automatic placing you into a folder when you log on can not be disabled.
Isolate Users
When you use the Isolate Users option the user will be placed into a folder and this folder becomes the root of the FTP site for their session. They can not back up to the real FTP site Home Directory, they are in effect Isolated.
There are a number of differences depending on the configuration of the server as shown below:
FTP Server Name User Account Isolation Folder User Folder
FTP-SRV-01 Anonymous LocalUser Public
FTP-SRV-01 FTP-SRV-01\User LocalUser User
FTP-SRV-01 Domain\User Domain User
The main points to take from the above is that:
  • If the user logs in Anonymously and Isolate Users is enabled then the Isolation Folder is called "LocalUser" and the users folder is called "Public".
  • If the User Account that the user is logging in with is an account on the local FTP Server computer then "LocalUser" is the name of the Isolation folder as long as the FTP server is not running on a Domain Controller.
  • If the User Account that the user is logging in with is a Domain Account then the "Domain" is the name of the Isolation folder.
Here is an example of the location of the folders:
Directory Description
c:\inetpub\ftproot The FTP sites home directory
c:\inetpub\ftproot\LocalUser The Isolation folder
c:\inetpub\ftproot\LocalUser\Public The users folder if logging in anonymously
c:\inetpub\ftproot\LocalUser\XYZ The user'�s folder if logging in as the Local Account "XYZ"
c:\inetpub\ftproot\Domain\XYZ The user�s folder if logging in as the "Domain" Account "XYZ"
Note: Where Domain is references above change it to the name of your Windows Domain.
Note: When you create an FTP site with Isolated users you need to create the LocalUser or the Domain folder as well as all user account folders.






Friday, April 26, 2013

What Port is Named Instance of SQL Server Listening On?

exec xp_readerrorlog 1 , 1 , N'listen' It works on 2008 and lower, is said to work on 2012. exec xp_readerrorlog [log #, 1 is current] , [1 – sql server log, 2 – agent log, 3 – full text log] , [search string] http://mssqlwiki.com/2011/02/13/beyond-xp_readerrorlog/

Wednesday, April 17, 2013

Solution to Apostrophes in Email Addresses (.Net)

It should work - http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/84dd5b66-f68d-4b0c-823f-25aa7c7b4d6b/ i.e. create MailAddress("myFirstName.O'Reilly@mywebsite.com"), and then use that to create a MailMessage, and pass to SmtpClient.Send.

Tuesday, April 16, 2013

HTML5 Resources


HTML5 video - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/HTML5_video

Slides, A Slideshow Plugin for jQuery
http://slidesjs.com/


We love HTML5 games - Ludei
 ludei.com

CSS3 Keyframe Animation Demo
 impressivewebs.com

Sass - Syntactically Awesome Stylesheets
 sass-lang.com

Sencha Fastbook
 vimeo.com

This four-minute video gives you a quick overview of Sencha Fastbook, and shows you a side-by-side comparison of how well our HTML5 app performs against both the native iOS and the native Android Facebook apps (versions 5.2 and 1.9.12 respectively, the latest available when we made this video on December 10th).
Douglas Crockford's Javascript
 crockford.com

stack.jpg
 dropbox.com

CSS3 2D Transforms
 w3schools.com

Touchy-stuff by vainrobot
 github.com

jQuery Mobile | jQuery Mobile
 jquerymobile.com

Understanding CSS Filter Effects - HTML5 Rocks
 html5rocks.com

Filter Effects - SVG 1.1 - 20030114
 w3.org
Draggable
 jqueryui.com

HTML5 Rocks - Native HTML5 Drag and Drop
 html5rocks.com

html5rocks com
 html5rocks.com

jQuery Tutorial for Beginners: Nothing But the Goods | Impressive Webs Toronto
 impressivewebs.com

JavaScript Tutorial
 w3schools.com

http://code.jquery.com/jquery-1.9.1.min.js
 jquery.com

.click() – jQuery API
 jquery.com

 delicious.com
 delicious.com

Solving Performance for 2D & 3D Web Apps: Finally! - Marakana
 marakana.com

 An Introduction To CSS3 Keyframe Animations - Smashing Coding
 smashingmagazine.com

SVG-edit
 googlecode.com

Swelen JavaScript Beauty - Online JS Beautifier With Colors
 swelen.com

Google Font Directory
 google.com

Normalize.css: Make browsers render all elements more consistently.
 github.com

HTML5 Reset Stylesheet
 html5doctor.com

The W3C Markup Validation Service
 w3.org

Sublime Text - Download
 sublimetext.com

https://marakana.com/static/courseware/html5/blocky_blog_image.png
 marakana.com

W3Schools Online Web Tutorials
 w3schools.com

Dart : Structured web programming
 dartlang.org

AngularJS — Superheroic JavaScript MVC Framework
 angularjs.org

Backbone.js
 backbonejs.org

PhoneGap API Documentation
 phonegap.com

PhoneGap Build
 phonegap.com

Firefox at Mobile World Congress 2013 — mozilla.org
 mozilla.org

Earth Hour | WWF France
 earthhour.fr

http://three.js/
 three.js

Vows « Asynchronous BDD for Node
 vowsjs.org

HTML datalist Tag
 w3schools.com

JavaScript UI widgets | Kendo UI
 kendoui.com

John Resig - HTML5 Shiv
 ejohn.org

Angry Birds Volcano
 angrybirds.com

HexGL, the HTML5 futuristic racing game.
 bkcore.com
webghl game

Sencha Fastbook on Vimeo
2 months ago
 vimeo.com
facebook vs snecha

Soul Reaper - HTML5 Scroll Book
 soul-reaper.com

HTML5 Cross Browser Polyfills · Modernizr/Modernizr Wiki · GitHub
 github.com
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

PhoneGap
 phonegap.com

Modernizr
 modernizr.com

Kendo UI - The Art of Web Development
 kendoui.com
Everything developers need to build html5/js sites and mobile apps. jQuery based toolset that includes rich UI widgets, powerful data source, dynamic data visualizations, and blazing fast micro-templates, all backed by industry leading professional support.

HTML5 Rocks - A resource for open web HTML5 developers
 html5rocks.com

Ultimate CSS Gradient Generator - ColorZilla.com
 colorzilla.com   css
A powerful Photoshop-like CSS gradient editor




















































Monday, March 11, 2013

(Re-Copy) Why Javascript Returns Zero For parseInt('08') and parseInt('09')?

http://www.ventanazul.com/webzine/articles/issues-parseint-javascript Why Javascript Returns Zero For parseInt('08') and parseInt('09')? Writing a simple Javascript function to create a Date object from a 'yyyy-mm-dd' string I found a small, but important, issue with the parseInt function, used to transform strings to integers. Both parseInt('08') and parseInt('09') return zero because the function tries to determine the correct base for the numerical system used. In Javascript numbers starting with zero are considered octal and there's no 08 or 09 in octal, hence the problem. To fix this just add the second parameter for parseInt, the base to be used for the conversion. The correct calls should be parseInt('08', 10) and parseInt('09', 10). Another of those little details, uh? Posted to Articles, javascript, tips on Wed, 2008-07-02 17:03

Wednesday, February 27, 2013

SSIS - DTS - Agent Permissions

http://technet.microsoft.com/en-us/library/ms188283.aspx SQL Server Agent Fixed Database Roles SQL Server 2012 Other Versions 3 out of 8 rated this helpful - Rate this topic SQL Server 2005 introduced the following msdb database fixed database roles, which give administrators finer control over access to SQL Server Agent. The roles listed from least to most privileged access are: SQLAgentUserRole SQLAgentReaderRole SQLAgentOperatorRole When users who are not members of one of these roles are connected to SQL Server in SQL Server Management Studio, the SQL Server Agent node in Object Explorer is not visible. A user must be a member of one of these fixed database roles or a member of the sysadmin fixed server role to use SQL Server Agent. Permissions of SQL Server Agent Fixed Database Roles The SQL Server Agent database role permissions are concentric in relation to one another -- more privileged roles inherit the permissions of less privileged roles on SQL Server Agent objects (including alerts, operators, jobs, schedules, and proxies). For example, if members of least-privileged SQLAgentUserRole have been granted access to proxy_A, members of both SQLAgentReaderRole and SQLAgentOperatorRole automatically have access to this proxy even though access to proxy_A has not been explicitly granted to them. This may have security implications, which are discussed in the following sections about each role. SQLAgentUserRole Permissions SQLAgentUserRole is the least privileged of the SQL Server Agent fixed database roles. It has permissions on only operators, local jobs, and job schedules. Members of SQLAgentUserRole have permissions on only local jobs and job schedules that they own. They cannot use multiserver jobs (master and target server jobs), and they cannot change job ownership to gain access to jobs that they do not already own. SQLAgentUserRole members can view a list of available proxies only in the Job Step Properties dialog box of SQL Server Management Studio. Only the Jobs node in SQL Server Management Studio Object Explorer is visible to members of SQLAgentUserRole. Security noteSecurity Note Consider the security implications before granting proxy access to members of the SQL Server Agentdatabaseroles. The SQLAgentReaderRole and the SQLAgentOperatorRole are automatically members of the SQLAgentUserRole. This means that members of SQLAgentReaderRole and SQLAgentOperatorRole have access to all SQL Server Agent proxies that have been granted to the SQLAgentUserRole and can use those proxies. The following table summarizes SQLAgentUserRole permissions on SQL Server Agent objects. 1 Cannot change job ownership. 2 Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio. 3 List of proxies only available in the Job Step Properties dialog box of Management Studio. 4 Members of SQLAgentUserRole must explicitly be granted the EXECUTE permission on sp_purge_jobhistory to delete job history on jobs that they own. They cannot delete job history for any other jobs. SQLAgentReaderRole Permissions SQLAgentReaderRole includes all the SQLAgentUserRole permissions as well as permissions to view the list of available multiserver jobs, their properties, and their history. Members of this role can also view the list of all available jobs and job schedules and their properties, not just those jobs and job schedules that they own. SQLAgentReaderRole members cannot change job ownership to gain access to jobs that they do not already own. Only the Jobs node in SQL Server Management Studio Object Explorer is visible to members of the SQLAgentReaderRole. Security noteSecurity Note Consider the security implications before granting proxy access to members of the SQL Server Agentdatabaseroles. Members of SQLAgentReaderRole are automatically members of the SQLAgentUserRole. This means that members of SQLAgentReaderRole have access to all SQL Server Agent proxies that have been granted to SQLAgentUserRole and can use those proxies. 1 Cannot change job ownership. 2 Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio. 3 List of proxies only available in the Job Step Properties dialog box of Management Studio. 4 Members of SQLAgentReaderRole must explicitly be granted the EXECUTE permission on sp_purge_jobhistory to delete job history on jobs that they own. They cannot delete job history for any other jobs. SQLAgentOperatorRole Permissions SQLAgentOperatorRole is the most privileged of the SQL Server Agent fixed database roles. It includes all the permissions of SQLAgentUserRole and SQLAgentReaderRole. Members of this role can also view properties for operators and proxies, and enumerate available proxies and alerts on the server. SQLAgentOperatorRole members have additional permissions on local jobs and schedules. They can execute, stop, or start all local jobs, and they can delete the job history for any local job on the server. They can also enable or disable all local jobs and schedules on the server. To enable or disable local jobs or schedules, members of this role must use the stored procedures sp_update_job and sp_update_schedule. Only the parameters that specify the job or schedule name or identifier and the @enabled parameter can be specified by members of SQLAgentOperatorRole. If they specify any other parameters, execution of these stored procedures fails. SQLAgentOperatorRole members cannot change job ownership to gain access to jobs that they do not already own. The Jobs, Alerts, Operators, and Proxies nodes in SQL Server Management Studio Object Explorer are visible to members of SQLAgentOperatorRole. Only the Error Logs node is not visible to members of this role. Security noteSecurity Note Consider the security implications before granting proxy access to members of the SQL Server Agentdatabaseroles. Members of SQLAgentOperatorRole are automatically members of SQLAgentUserRole and SQLAgentReaderRole. This means that members of SQLAgentOperatorRole have access to all SQL Server Agent proxies that have been granted to either SQLAgentUserRole or SQLAgentReaderRole and can use those proxies. 1 Can get list of available operators for use in sp_notify_operator and the Job Properties dialog box of Management Studio. 2 Cannot change job ownership. 3SQLAgentOperatorRole members can enable or disable local jobs they do not own by using the stored procedure sp_update_job and specifying values for the @enabled and the @job_id (or @job_name) parameters. If a member of this role specifies any other parameters for this stored procedure, execution of the procedure will fail. 4SQLAgentOperatorRole members can enable or disable schedules they do not own by using the stored procedure sp_update_schedule and specifying values for the @enabled and the @schedule_id (or @name) parameters. If a member of this role specifies any other parameters for this stored procedure, execution of the procedure will fail. Assigning Users Multiple Roles Members of the sysadmin fixed server role have access to all SQL Server Agent functionality. If a user is not a member of the sysadmin role, but is a member of more than one SQL Server Agent fixed database role, it is important to remember the concentric permissions model of these roles. Because more privileged roles always contain all the permissions of less privileged roles, a user who is a member of more than one role automatically has the permissions associated with the most privileged role that the user is a member of.

Friday, February 22, 2013

All Variables Named After Food

http://jacquesmattheij.com/The+worst+program+I+ever+worked+on Not trying to boost content, just love this tale and do not want to loose it... ------------------------------------------------------------------------------------------- The Worst Program I Ever Worked On Mar 16th, 2011 Most contract jobs fade pretty quickly in memory after the work is done, but some you remember for the rest of your life. This is one of the latter variety. This happened long ago, at a (fair sized) company that shall remain nameless. The software was a chunk of code that had been maintained by a single guy that had been fired recently and was a core component of a commercial system. So far nothing unusual, companies tend to find out that they have a piece of critical knowledge in one head all the time, usually if something happens to or with such a person there is a mild panic, some days of frantic reading and then life continues. Not so in this case. Some bug had popped up in this program and the guy assigned to fix it had come back alternatively laughing and crying babbling nonsense about ‘pizzas calling hamburgers and passing booze’. The programmer that had written this code had his own sense of humor and his own ideas about the term ‘job security’. We’ve all heard the tall stories about the accounting package that wipes all records if there is no payment to some off-shore bankaccount 48 hours after terminating some tech guy, but such tricks are relatively easy to deal with - assuming that most of those stories are true, which I have a hard time believing, and I’ve never seen any of those in real life. The software this guy left behind did not have any logic bombs or other nasty tricks in it, it compiled just fine, and besides that one bug it seemed to work fine as well. Imagine this though: every function and variable name in the program was named after food. Pizza’s, tomatoes, pickles, various kinds of cheese, fruits, vegetables, drinks and so on, for page after endless page. The only place where the names made any immediate sense was ‘main’ and any C stdlib calls. So I got handed the thankless job of working very hard to get the program back to a state where it could be maintained. It was a really nifty form of encryption, and only with a key in hand would the salad of code make any sense. Little by little I converted the program back by naming the functions and the variables with more sensible names, and as the work progressed it got easier and easier. Working backwards from a known function and source code is a lot easier than reverse assembly of unknown code (because then you first have to separate code/data and you have to figure out what the high level representation was, here I had the high level representation in plaintext in front of me), so it wasn’t that the job was impossible or even particularly hard, it was just tedious. Once a function or variable had been identified to have some probable meaning a new name was made and a search-and-replace took care of the actual renaming. Another problem was that it was bad code, in fact, the various spaghetti twists in the code did more to obfuscate the meaning of it than the lack of meaningful symbols, so once I had all the functions and variables renamed back to something that made sense I re-wrote a good bit of the code to make it easier to understand and work more efficient. I never did find out if he had a non-obfuscated version of the code that he ran through a ‘blender’ script that obfuscated the original code by stripping out any and all comments and replacing all symbols by nonsensical ones. I find it hard to get in to the mind of someone that does something like that to begin with but I find it even harder to imagine that he wrote code like that directly, that would have actually been an amazing feat. Of course, if in your head you think that they can’t fire you because your program makes no sense (or that they might hire you back) then you’re delusional so whatever goal this guy had with his trick it failed in a terrible way (I can’t imagine him giving his former employer as a reference either) but it made for an amusing couple of weeks, and a very happy customer.

Thursday, February 7, 2013

Bulk Insert

UtilSQL.DML.DBExecNonQueryText("TRUNCATE TABLE foo;", "bar"); using (SqlDataReader portal = UtilSQL.DML.DBExecReader("EXEC myproc", "mate")) { using (SqlConnection conn = UtilSQL.DML.GetSQLConnString("bar")) { conn.Open(); /// Note: for SqlBulkCopy to work the columns must be identically named /// and typed and all fields in the record must be copied or else you /// get a useless error about "LocaleID" /// /// Turns out that using SQLBulkCopy in the middle tier is faster than an /// insert using linked servers even if the data is prepped in a temp table /// first SqlBulkCopy bulk = new SqlBulkCopy(conn); bulk.DestinationTableName = "destTable"; // UID Username LastName FirstName Email isAdmin Inactive CostCenter Descr Bud_Read Bud_Write Facility SqlBulkCopyColumnMapping mapping1 = new SqlBulkCopyColumnMapping("UID", "UID"); SqlBulkCopyColumnMapping mapping2 = new SqlBulkCopyColumnMapping("Username", "Username"); SqlBulkCopyColumnMapping mapping3 = new SqlBulkCopyColumnMapping("LastName", "LastName"); SqlBulkCopyColumnMapping mapping4 = new SqlBulkCopyColumnMapping("FirstName", "FirstName"); SqlBulkCopyColumnMapping mapping5 = new SqlBulkCopyColumnMapping("Email", "Email"); SqlBulkCopyColumnMapping mapping6 = new SqlBulkCopyColumnMapping("isAdmin", "isAdmin"); SqlBulkCopyColumnMapping mapping7 = new SqlBulkCopyColumnMapping("Inactive", "Inactive"); SqlBulkCopyColumnMapping mapping8 = new SqlBulkCopyColumnMapping("CostCenter", "CostCenter"); SqlBulkCopyColumnMapping mapping9 = new SqlBulkCopyColumnMapping("Descr", "Descr"); SqlBulkCopyColumnMapping mapping10 = new SqlBulkCopyColumnMapping("Bud_Read", "Bud_Read"); SqlBulkCopyColumnMapping mapping11 = new SqlBulkCopyColumnMapping("Bud_Write", "Bud_Write"); SqlBulkCopyColumnMapping mapping12 = new SqlBulkCopyColumnMapping("Facility", "Facility"); bulk.ColumnMappings.Add(mapping1); bulk.ColumnMappings.Add(mapping2); bulk.ColumnMappings.Add(mapping3); bulk.ColumnMappings.Add(mapping4); bulk.ColumnMappings.Add(mapping5); bulk.ColumnMappings.Add(mapping6); bulk.ColumnMappings.Add(mapping7); bulk.ColumnMappings.Add(mapping8); bulk.ColumnMappings.Add(mapping9); bulk.ColumnMappings.Add(mapping10); bulk.ColumnMappings.Add(mapping11); bulk.ColumnMappings.Add(mapping12); bulk.WriteToServer(portal); bulk.Close(); conn.Close(); recCountPortal = UtilSQL.DML.DBExecScalarInt64("SELECT COUNT (*) FROM destTable", "bar"); } } this.lblPortal.Text = recCountPortal.ToString() + " records from portal.";

Wednesday, January 30, 2013

Blank Browser Edit Page

data:text/html, < html contenteditable > no space next to angle brackets

Tuesday, January 8, 2013

SQL Server Find Table Fragmentation

SELECT db.Name , OBJECT_NAME(s.OBJECT_ID) , s.avg_fragmentation_in_percent Perc FROM sys.dm_db_index_physical_stats (NULL, NULL, NULL, NULL, NULL) s JOIN MASTER.DBO.SYSDATABASES db ON s.database_id = db.dbID WHERE s.database_id = 7 ORDER BY Perc Desc

Tuesday, December 18, 2012

SQL for Validate Email

http://stackoverflow.com/questions/229824/tsql-email-validation-without-regex SELECT email FROM #Email where email like '%[^a-z,0-9,@,.]%' or email not like '%_@_%_.__%'

Friday, October 19, 2012

Find Date of Last Restore

http://www.mssqltips.com/sqlservertip/1860/identify-when-a-sql-server-database-was-restored-the-source-and-backup-date/
 
SELECT [rs].[destination_database_name], 
[rs].[restore_date], 
[bs].[backup_start_date], 
[bs].[backup_finish_date], 
[bs].[database_name] as [source_database_name], 
[bmf].[physical_device_name] as [backup_file_used_for_restore]
FROM msdb..restorehistory rs
INNER JOIN msdb..backupset bs
ON [rs].[backup_set_id] = [bs].[backup_set_id]
INNER JOIN msdb..backupmediafamily bmf 
ON [bs].[media_set_id] = [bmf].[media_set_id] 
ORDER BY [rs].[restore_date] DESC

Wednesday, October 10, 2012

IE7 and IE8 Serif / Letter Tail Cut Off

line-height: normal;
 
http://stackoverflow.com/questions/634824/ie7-is-clipping-my-text-how-do-i-adjust-its-attitude
 
 

Thursday, September 20, 2012

HTML Table - Text Not Centered in Headers

At least for IE7, TH widths should be declared as %'s, not px.

Monday, September 17, 2012

Fun with Dynamic SQL - Abusing the Data Layer

I needed to do some reporting on a process from within the db, essentially output a table of values to an email for alerting purposes ... enjoy!


Period

Records

Charges

1301

55975

523110523.76

1302

58820

554884666.09

1303

0

0.00

1304

0

0.00

1305

0

0.00

1306

0

0.00

1307

0

0.00

1308

0

0.00

1309

0

0.00

1310

0

0.00

1311

0

0.00

1312

0

0.00



-------------------------------------------------------------------

ALTER PROC schema.getChargeCounts (@currentFY CHAR (2), @tOut VARCHAR (MAX) OUTPUT)
AS
BEGIN

/**************************************************************************
Joe Kelly
2012-09-17 17:43:59.300

Returns an HTML table of late charge information based up on the two digit
year entered.

DECLARE @V VARCHAR (maX) = ''
EXEC schema.getChargeCounts @currentFY = '13', @tOut = @V OUTPUT
SELECT @V

**************************************************************************/

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SET NOCOUNT ON

DECLARE @rowCount INT = 12
, @iter INT = 1
, @Period CHAR (4) = ''
, @tStart CHAR (256) = ''
, @tEnd CHAR (8) = '
'
, @tHead CHAR (512) = 'PeriodRecordsCharges'
, @tRStart CHAR (256) = ''
, @tREnd CHAR (8) = ''
, @tDStarCC CHAR (256) = ''
, @tDStartR CHAR (256) = ''
, @tDEnd CHAR (8) = ''
, @SQL NVARCHAR (MAX) = ''

DECLARE @Report TABLE (
ident INT IDENTITY (1, 1)
, Period INT
, Records BIGINT
, Charges MONEY
)

DECLARE @ReportOut TABLE (
ident INT IDENTITY (1, 1)
, Period INT
, Records BIGINT
, Charges MONEY
)

SELECT @SQL = 'SELECT lc.Period, Count (*) Records , Sum (Charge) Charges
FROM dbo.Charge_FY' + CAST (@currentFY AS CHAR (2)) + ' LC
WHERE ' + CAST (@currentFY AS CHAR (2)) + ' = LEFT (lc.Period, 2)
GROUP BY lc.Period '

INSERT @Report (
Period
, Records
, Charges
)
EXEC sp_EXECUTESQL @SQL

WHILE (@iter <= 12)
BEGIN
SELECT @Period = @currentFY + RIGHT (CAST (REPLICATE ('0', 2) AS VARCHAR (2)) + CAST (@iter AS VARCHAR (3)), 2)

INSERT @ReportOut (
Period
, Records
, Charges
)
SELECT @Period
, 0
, 0

SELECT @iter += 1
END

UPDATE RO
SET ro.Records = r.Records
, ro.Charges = r.Charges
FROM @ReportOut RO
JOIN @Report r
ON ro.period = r.period

SELECT @tOut +=
@tStart
+ @tHead

SELECT @iter = 1

WHILE (@iter <= 12)
BEGIN
SELECT @tOut +=
@tRStart
+ @tDStarCC
+ CAST (Period AS VARCHAR (64))
+ @tDEnd
+ @tDStartR
+ CAST (Records AS VARCHAR (64))
+ @tDEnd
+ @tDStartR
+ CAST (CONVERT (MONEY, Charges, 2) AS VARCHAR (64))
+ @tDEnd
+ @tREnd
FROM @ReportOut
WHERE ident = @iter

SET @iter += 1

END

SELECT @tOut += @tEnd

SELECT @tOut = REPLACE (REPLACE (REPLACE (@tOut, ' ', ''), ' ', ''), ' ', '')

END

Tuesday, September 4, 2012

Funky IE Appearance Upon Deployment - Intranet

Fix: < meta http-equiv="X-UA-Compatible" content="IE=8" / >


Source: http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx

Note for intranet sites the default is 7, not 8.

Unfortunately the default compatibility mode for intranet sites is set to "On" in IE.

Thursday, August 30, 2012

jquery with Master Pages and Subdirectories - Correct Path Syntax

Error:" $ is not defined"

Helpful: http://stackoverflow.com/questions/2194992/jquery-is-not-defined

Use the net tab in firebug to make sure the URI is being written out and is being loaded.

Syntax:

[script type="text/javascript" src="../Scripts/jquery/jquery.1.8.0.dev.js" ][/script]

Verified for FF & IE.



Tuesday, August 21, 2012

IIS 6.0 Local User Security


A common site configuration issue (non-AD):

KCTS - Make sure the root of your FTP site is not the localuser(s) folder itself but its parent folder.

http://forums.devshed.com/ftp-help-113/iis-6-isolate-user-ftp-91708.html

Thursday, August 9, 2012

VB6 DLL Web Deployment Errors

ASP_0177_:_800401f3|Server.CreateObject_Failed
ActiveX_component_can't_create_object


' "ASP_0177_:_800401f3" means that the component either has not been registered or that
' the name that was passed to call it is bad (http://forums.iis.net/t/1122303.aspx)
'
' Check that the dll has been registered and that the correct case is being used
' both in the build and the call (not sure if it is case sensitive)
'
' If component fails on deployment make sure that all class modules have
' "5 - Multiuse" selected for their "instancing" property

VB6 DLL Web Deployment

ASP_0177_:_800401f3|Server.CreateObject_Failed
ActiveX_component_can't_create_object

Hook to Debug VB6 ActiveX DLL

'Public Sub Main()
'
' 'Note that switching from an ActiveX DLL to a Standard EXE may/will change the ' class module “Instancing” property from “Multiuse” to “Private” (error: “No
' ' creatable public component detected". To get back to the ActiveX DLL change the ' class module “Instancing” property back to “Multiuse”
'
' Dim sError, vTable, WriteAccess, RowCount
' ' name of class that contains the function to invoke
'
' Dim foo As New cReports
'
' Dim sPEDate, sL5, sL4, sL3, sL2, sL1, sCC, sFrom, sTxtMonth, states(12), hFromRev, hSortBy
' Dim vReportDataarray(3), TimePeriod, sType
' Dim sUsername, oUCSF
' Dim ARows, BRows, CRows, DRows, ERows, ZRows
'
' sPEDate = "1211"
' sCC = "1742001 "
' hSortBy = "ActRevenue"
'
' ' invoke function
' sError = foo.getRPT_MEV_CC_Revenue_Detail(sPEDate, vReportDataarray, sUsername, sCC, ARows, BRows, CRows, DRows, ERows, ZRows, states, hSortBy)
'
' 'F8 – away!
'
' 'modal for a breakpoint
' MsgBox Command$, vbOK, "Command Line params"
'
'End Sub

Great Powershell Script - Directory Size Recursively

http://technet.microsoft.com/en-us/library/ff730945.aspx

$startFolder = "C:\Scripts" $colItems = (Get-ChildItem $startFolder | Measure-Object -property length -sum) "$startFolder -- " + "{0:N2}" -f ($colItems.sum / 1MB) + " MB" $colItems = (Get-ChildItem $startFolder -recurse | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) foreach ($i in $colItems) { $subFolderItems = (Get-ChildItem $i.FullName | Measure-Object -property length -sum) $i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB" }

Tuesday, July 31, 2012

Is Agent Job Running???

CREATE PROC portal.isJobRunning (@jobName VARCHAR (256))
AS
BEGIN

/**************************************************************************
Joe Kelly
2012-07-31 17:56:04.540

Determines if a job is running or not

EXEC portal.isJobRunning @jobName = 'Export%'

Template source:
http://weblogs.asp.net/johnbilliris/archive/2009/10/13/how-to-determine-if-a-sql-job-is-running.aspx

**************************************************************************/
SET NOCOUNT ON

DECLARE @xp_results TABLE (
job_id UNIQUEIDENTIFIER NOT NULL
, last_run_date INT NOT NULL
, last_run_time INT NOT NULL
, next_run_date INT NOT NULL
, next_run_time INT NOT NULL
, next_run_schedule_id INT NOT NULL
, requested_to_run INT NOT NULL -- BOOL
, request_source INT NOT NULL
, request_source_id sysname COLLATE database_default NULL
, running INT NOT NULL -- BOOL
, current_step INT NOT NULL
, current_retry_attempt INT NOT NULL
, job_state INT NOT NULL
)

INSERT INTO @xp_results
EXECUTE master.dbo.xp_sqlagent_enum_jobs 1, 'dbo'

SELECT xpr.running
, sjv.name
FROM @xp_results xpr
JOIN MSDB.dbo.sysjobs_view sjv
ON xpr.job_id = sjv.job_id
WHERE sjv.name LIKE @jobName

END

Flight Recorder OLAP CUBE Trace


Default 5MB log on OLAP installations:

http://msdn.microsoft.com/en-us/library/ms174827.aspx (search for
FlightRecorder)

http://support.microsoft.com/kb/2128005

FlightRecorder

 

The events and columns captured by the Flight Recorder are controlled by a trace definition file.  The advanced server property named Log\FlightRecorder\TraceDefinitionFile controls the definition file used by the Fligth Recorder.  By default, the property is blank, which means the Flight Recorder defaults to using the trace file definition stored in the file flightrecordertracedef.xml, which is stored in the ..\OLAP\bin directory wherever SSAS is installed.

 http://social.msdn.microsoft.com/forums/en-US/sqlanalysisservices/thread/9bcc369d-5f23-41fc-916d-448e20182430

Monday, July 30, 2012

List of Tables in Access DB


Source???

SELECT MSysObjects.Name AS table_name FROM MSysObjects WHERE (((Left([Name],1))<>"~") AND ((Left([Name],4))<>"MSys") AND ((MSysObjects.Type) In (1,4,6))) order by MSysObjects.Name

Thursday, July 19, 2012

Debugging SSCode - UCSFMC

C# as a scripting language, WebForms with no code behind, no use of app_code, a single common page inheritance for errors and the use of external include files for calling external (from the page) methods - how to debug.

a.) Remove tag referring to .\SSCode\xx.cs

b.) Take contents (functions) of xx.cs and create a file in App_Code with the calling page's name and a class wrapper with the file name

c.) In xx.aspx change the page directive references to the new class and file name.

Monday, July 2, 2012

Classic ASP Errors on Large Result Set with No Information

Check the IIS log.

I this case the IIS buffer had to be increased.

Example log message: 2012-07-02 19:46:09 W3SVC1522741043 127.0.0.1 POST /Reports/Reports_Var_CC_Rev.asp |0|ASP_0251_:_80004005|Response_Buffer_Limit_Exceeded 655 UCSFMC\kellyjoe 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.2;+Trident/4.0;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.04506.30;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729;+.NET4.0C;+.NET4.0E;+InfoPath.3) 500 0 0

http://support.microsoft.com/kb/925764

Friday, June 8, 2012

runas syntax

C:\Users\epsi>runas /user:domain\user "D:\Program Files (x86)\Microsoft SQL
Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"