tag:blogger.com,1999:blog-67117272008-07-26T20:11:56.556-05:00Programmabilities Blogprogrammabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-6711727.post-8704578781301005332008-07-11T16:25:00.003-05:002008-07-11T16:48:43.010-05:00VB: Regular Expressions, etc...<pre>Regex.IsMatch("subject", "regex") ' Checks if the regular expression ' matches the subject string.</pre> <h3>VB: using Controls collection</h3> <pre>' Clears textbox controls' content on the form using ' Controls collection. Dim intX As Integer Do While intX < text = "" intx =" intX"></pre> <h3>ViewState("UrlReferrer")</h3> <pre><code>Sub Page_Load() If Page.IsPostBack = False Then ' Store URL Referrer to return to home page. ViewState("UrlReferrer") = Me.Request.UrlReferrer.ToString() End If End Sub Sub CancelBtn_Click() ' Redirect back to the home page. Me.Response.Redirect(CType(ViewState("UrlReferrer"), String)) End Sub</code></pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-64532593559893704052008-07-11T16:22:00.000-05:002008-07-11T16:23:04.274-05:00ASP confirm<pre><code> gt-a-s-p:button id="ConfirmOnClick" runat="server" onclientclick="return confirm('You\'re sure you want to do this?');" text="Launch Airstrike"> lt/ a-s-p:button> </code></pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-84140188835322302562008-07-11T16:17:00.000-05:002008-07-11T16:18:21.178-05:00ASP .NET set focus to a control (javascript)<pre>body onload="javascript:document.forms[0].txtFirst.focus();"</pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-24225728134203660972008-07-10T13:09:00.000-05:002008-07-10T13:12:26.254-05:00check for DbNullCheck for DbNull: <pre>< a s p :Label runat="server" ID="Label6" Text='< % # IIF(Typeof( Eval("ShippedDate")) IS DbNull,"No Date",Eval("ShippedDate")) % >' /></pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-1662174184384557472008-07-03T15:06:00.002-05:002008-07-15T14:29:25.857-05:00Search Stored ProceduresThis searches all the Stored Procedures in 1 SQL Server database for the said string. I tested it in Query Analyzer and it found all the Stored Procedures that had occurrences of my "lq_Campaign" in 1 database: <pre>SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%lq_Campaign%' AND ROUTINE_TYPE='PROCEDURE'</pre> <h4>Here is another way</h4> <p> Below query you can searcg any table, stored procedure or views what ever has that expression as a column or object name. </p> <pre>SELECT * FROM SYSOBJECTS WHERE ID IN (SELECT ID FROM SYSCOMMENTS WHERE TEXT LIKE ‘%PRODUC%’)</pre> <p> The query produced all the object names--where ever it finds expression like ‘PRODUC‘. </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-42969689359957410672008-07-03T08:28:00.002-05:002008-07-03T08:32:40.638-05:00Model View Controller<ul> <li>Primary goal is to separate the things that change from the things that do not.</li> <li>Model is the data representation.</li> <li>View is the presentation of the model.</li> <li>Controller responds to events and modifies the model.</li> <li>Model notifies the views to update the presentation.</li> </ul><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-42983465517499069142008-05-09T12:51:00.017-05:002008-06-23T13:32:03.557-05:00SQL Server 2005 Reports: tips<ACRONYMN title="SQL Server Reporting Services">SSRS</ACRONYMN>: <ul> <li> Page Header: <ul> <li> TextBox via Expression...: <code>=Globals.ReportFolder &amp; Globals.ReportName </code> </li> </ul> </li> <li> Page Footer: <ul> <li> Page Footer: TextBox via Expression...: <code>=Format(Globals!PageNumber) & " of " & Format(Globals!TotalPages) & " pages"</code> </li> <li> <code>="Printed by " & User!UserID & " on " & DateTime.Now.ToString()</code> </li> <li> <code>="Execution Time: " & IIF(System.DateTime.Now.Subtract(Globals!ExecutionTime).TotalSeconds < 1, "0 seconds", ( IIF(System.DateTime.Now.Subtract(Globals!ExecutionTime).Hours > 0, System.DateTime.Now.Subtract(Globals!ExecutionTime).Hours & " hour(s), ", "") & IIf(System.DateTime.Now.Subtract(Globals!ExecutionTime).Minutes > 0, System.DateTime.Now.Subtract(Globals!ExecutionTime).Minutes & " minute(s), ", "") & IIf(System.DateTime.Now.Subtract(Globals!ExecutionTime).Seconds > 0, System.DateTime.Now.Subtract(Globals!ExecutionTime).Seconds & " second(s)", "")) )</code> </li> </ul> </li> <li> Body: <ul> <li> TextBox via Expression...: <code>=Format(Sum(Fields!Account.Value), "C0")</code> (Works if column is numeric data type.) </li> <li> Alternate rows by adding the following to the row via Properties > BackgroundColor expression of your detail row: <code>=IIF(RowNumber(Nothing) Mod 2, "White", "Gainsboro")</code> </li> </ul> </li> </ul> <ul> <li> <a href="http://msdn.microsoft.com/en-us/library/aa337293.aspx">msdn.microsoft.com/en-us/library/aa337293.aspx</a> </li> <li> *<a href="http://en.csharp-online.net/Building_Reports_in_SQL_Server_2005">en.csharp-online.net/Building_Reports_in_SQL_Server_2005</a> </li> <li> *<a href="http://ssw.com.au/Ssw/Standards/Rules/RulesToBetterSQLReportingServices.aspx">ssw.com.au/Ssw/Standards/Rules/RulesToBetterSQLReportingServices.aspx</a> </li> <li> <a href="http://download.microsoft.com/download/1/3/4/134644fd-05ad-4ee8-8b5a-0aed1c18a31e/reporting_services_design.doc">download.microsoft.com/download/1/3/4/134644fd-05ad-4ee8-8b5a-0aed1c18a31e/reporting_services_design.doc</a> </li> <li> <a href="http://notethat.blogspot.com/2007/10/reporting-services-tips-tricks-and.html">notethat.blogspot.com/2007/10/reporting-services-tips-tricks-and.html</a> </li> </ul><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-42640245324270325502008-03-28T17:23:00.027-05:002008-04-21T20:24:49.074-05:00SSIS > VS Export wizard: table to ExcelAfter using the <acronym title="SQL Server Integration Services">SSIS</acronym> > VS <strong>Export</strong> wizard for table to Excel, you must add <code>DROP TABLE Query</code> to the <strong>Event Handlers</strong> tab or else it will error the second time it is reRun. <a href="http://programmabilities.com/blog/uploaded_images/ssis_Export_Excel-702445.bmp"><img style="display:block; margin:0px auto 5px; text-align:center;cursor:pointer; cursor:hand;" src="http://programmabilities.com/blog/uploaded_images/ssis_Export_Excel-702314.bmp" border="0" alt="SSIS" /></a> <h3><acronym title="SQL Server Integration Services">SSIS</acronym> > VS <strong>Import</strong> wizard for Excel to table: </h3> <ul><li>Be sure to only checkmark <tt>Results$</tt>.</li> <li>Be sure to Select Delete table option.</li> <li>Be sure to Change <tt>Results$</tt> name to Destination table name.</li> <li>If there is an error, it is often because a row in Excel has a NULL but the table column is NOT NULL (so add a blank to the Excel field).</li> </ul><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-83230021437864836592008-03-07T14:43:00.005-06:002008-04-18T11:27:02.493-05:00ReplaceCommasWithPipes.vbs<pre>' Currently this VBScript is set to replace-commas-with-pipes for every file that is 'in the folder where this VBScript sits: ' Before run it do the following: ' 1. Open VBScript in text editor ' 2. Set the parameters: ' cFolder_Name = "." ' current directory ' cOnlyOneFile = False ' set to True if I want to process only one file with name set below ' cOnlyFileName = "thisfile.csv" ' 3. Place the VBScript into the target folder ' 4. Run it by double-click ' Notes: http://groups.google.com/group/microsoft.public.excel.misc/browse_thread/thread/79ddd204ebb88287/be5d195da9241df9%23be5d195da9241df9 ' ------------------------------------------------------- On Error Resume Next const cFolder_Name = "." ' current directory const cOnlyOneFile = False ' False, So all files in the folder. const cOnlyFileName = "thisfile.csv" ' Uses this if the above was True (only wanted to process 1 file). Set oFSO = CreateObject("Scripting.FileSystemObject") ' Get folder: Set oFolder = oFSO.GetFolder(cFolder_Name) If oFolder Is Nothing Or Err.Number <> 0 Then MsgBox "Can't get a folder for search files. " + vbCRLF + "Please check the folder name." + vbCRLF + Err.Description, vbCritical, "Fatal error!" ' I will probably comment this out when this VBScript runs automatically as a scheduled job. End If Set oFiles = oFolder.Files If Err.Number <> 0 Or oFiles Is Nothing Then MsgBox "Can't get a list of files of folder." + vbCRLF + "" + vbCRLF + Err.Description, vbCritical, "Fatal error!" ' I will probably comment this out when this VBScript runs automatically as a scheduled job. End If Cnt = CInt(0) For Each oFile In oFiles If oFSO.GetExtensionName(oFile.Name) = "csv" Then ' Checks for "csv" file extension. If (cOnlyOneFile And (oFile.Name = cOnlyFileName)) Or (Not cOnlyOneFile) Then Call ReplaceSymbols(oFile.Name) Cnt = Cnt + 1 End If End If Next Senmail() MsgBox "Replacing is done. Total number of files had been processed: " + CStr(Cnt), vbExclamation, "Message..." ' I will probably comment this out when this VBScript runs automatically as a scheduled job. ' cleanup Set oFiles = Nothing Set oFSO = Nothing ' Find-and-replace: Sub ReplaceSymbols(oFileName) ' AKA "File.Name". If oFSO.FileExists(oFileName) Then Set oTextFile = oFSO.OpenTextFile(oFileName, 1, False) sFileContents = oTextFile.ReadAll oTextFile.Close Set oRegEx = CreateObject("VBScript.RegExp") With oRegEx .Global = True .IgnoreCase = False .Pattern = "," ' Or vbTab or "|" etc... sFileContents = .Replace(sFileContents, "|") ' .Pattern = "\|" ' reverse replacing ' sFileContents = .Replace(sFileContents, ",") End With Set oNewFile = oFSO.CreateTextFile(oFileName, True) ' Maybe oNewFile is not needed--it just could have been called oTextFile. oNewFile.Write sFileContents oNewFile.Close End If End Sub ' NOTE: This first way would only work on my PC, not on the other user's PCs; so I must use the second snippet, Senmail(), at the bottom. NOTE: If I made the changes marked "future testing" this might work. ' Send email to Jon Doe. --If the PC this runs on is not set right, this email will not get sent. 'Set oMessage = CreateObject("CDO.Message") 'oMessage.From = "Generated automatically for AWARE <jon.doe@jd.com>" ' NOTE: If future testing: Comment this out. 'oMessage.To = "jon.doe@jd.com,jon.doe2@jd.com" ' NOTE: If future testing: Should be ";". 'oMessage.Subject = "AWARE: Extracts done." 'oMessage.Sender = "jon.doe@jd.com" ' NOTE: If future testing: Comment this out. 'oMessage.TextBody = "AWARE: Commas replaced with pipes." 'oMessage.Send ' NOTE : Is using MS Outlook API to send e-mails. So check If MS Outlook installed on a workstation before a using of this script. Sub Senmail() Set objOutlook = CreateObject("Outlook.Application") Set objOutlookMsg = objOutlook.CreateItem(0) With objOutlookMsg ' This line caused it not to even popup warning, so leave it off: .From = "jon.doe@jd.com <jon.doe@jd.com>" ' "Generated automatically for AWARE <jon.doe@jd.com>" .To = "jon.doe@jd.com; jon.doe2@jd.com; jon.doe3@jd.com; jon.doe4@jd.com" .Subject = "AWARE: Extracts done." ' This line caused it not to even popup warning, so leave it off: .Sender = "jon.doe@jd.com" ' NOTE: jon.doe2's email is automatically inserted here because it is sent from here Outlook. .Body = "AWARE: Commas replaced with pipes. [Note: This message was generated and sent automatically.]" .Send End With Set objOutlookMsg = Nothing Set objOutlook = Nothing End Sub</pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-65900168180010441102008-03-06T12:28:00.009-06:002008-03-07T12:02:03.152-06:00Create SSIS to copy tables<p>An <acronym title="SQL Server Integration Services">SSIS</acronym> to copy tables from a Source to a Destination. Directions: </p> <ol> <li>From <strong>Start</strong>, select <strong>SQL Server Business Intelligence Development Studio</strong> </li> <li><strong>File</strong> <ol> <li><strong>New Project…</strong> <ol> <li><strong>Project types: Business Intelligence Projects</strong> </li> <li><strong>Integration Services Project…</strong> </li> <li>Click “<strong>OK</strong>” </li> </ol> </li> </ol> </li> <li><strong>Toolbox</strong> <ol> <li>Drag "<strong>Transfer SQL Server Objects Task</strong>" to "<strong>Control Flow</strong>" tab's pane. <ol> <li>Right-click choose <strong>Edit…</strong> <ol> <li><strong>Objects</strong> <ol> <li><strong>SourceConnection &#8249;New connection…&#8250;</strong> = NWDSQL </li> <li><strong>SourceDatabase</strong> = NIS_empl_wage </li> <li><strong>DestinationConnection &#8249;New connection…&#8250;</strong> = TESTSQL </li> <li><strong>DestinationDatabase</strong> = NIS_empl_wage </li> <li><strong>CopyData</strong> = <strong>True</strong> </li> <li><strong>ExistingData</strong> = <strong>Replace</strong> (so not append (dup errors)) </li> <li><strong>ObjectsToCopy</strong> (expand) <ol> <li><strong>CopyAllTables</strong> = <strong>True</strong> (so not sprocs) </li> </ol> </li> <li>Note: Leave all other options <strong>False</strong>. Ex., <strong>Table Options</strong>—Can leave all these <strong>False</strong> because it will just move data so Destination’s Primary Keys will remain. </li> </ol> </li> </ol> </li> <li>Click “<strong>OK</strong>” </li> </ol> </li> </ol> </li> <li>Save and Run </li> </ol> <p style="font-size:9pt;"> Note 1: Your <strong>Properties</strong> for the <strong>Transfer SQL Server Objects Task</strong> will now look like this: </p> <ol style="font-size:9pt;"> <li><strong>CopyAllTables</strong> = <strong>True</strong> (so not sprocs)</li> <li><strong>CopyData</strong> = <strong>True</strong></li> <li><strong>DestinationConnection</strong> = TESTSQL</li> <li><strong>DestinationDatabase</strong> = NIS_empl_wage</li> <li><strong>ExistingData</strong> = <strong>Replace</strong> (so not append (dup errors))</li> <li><strong>SourceConnection</strong> = NWDSQL</li> <li><strong>SourceDatabase</strong> = NIS_empl_wage</li> </ol> <p style="font-size:9pt;"> Note 2: A DB "restore" by the DBA would nix Destination tables that do not exist in Source tables; but not this technique. </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-78058818436517498472008-02-21T18:42:00.010-06:002008-03-07T12:10:48.310-06:00CASE: This way (3) NULLs get put in tbl if data is blank.<pre>command = New SqlCommand("INSERT INTO tblFoo (UIAcctNum, WorkZip, CheckRouteDesc, Agency, Division, RUN, Rpt_Unit_RUNDesc, StartDate,EndDate ,CheckRouteCode, Rpt_Unit_RUNDesc__old,NAICS) " & _ " VALUES (@UIAcctNum, @WorkZip, @CheckRouteDesc, @Agency, @Division, @RUN, " & _ "CASE WHEN ltrim(@Rpt_Unit_RUNDesc) = '' THEN NULL ELSE @Rpt_Unit_RUNDesc END, " & _ "@StartDate, " & _ "CASE WHEN ltrim(@EndDate) = '' THEN NULL ELSE @EndDate END, " & _ "@CheckRouteCode, " & _ "CASE WHEN ltrim(@Rpt_Unit_RUNDesc__old) = '' THEN NULL ELSE @Rpt_Unit_RUNDesc__old END, " & _ " CASE WHEN ltrim(@NAICS) = '' THEN NULL ELSE @NAICS END)", connection) ' This way (3) NULLs get put in tbl if data is blank.</pre><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-47808197855493629372007-12-09T22:00:00.009-06:002008-07-10T16:45:01.995-05:00SQL notes<ul> <li><code>SELECT * FROM ES202_RUN_LKP WHERE EndDate BETWEEN CAST('01/01/2005' AS DATETIME) AND CAST('01/11/2008' AS DATETIME) </code></li> <li><code>SELECT DISTINCT * INTO ##temp3 from ##temp2 --Use this if I want to INSERT rows AND create the destination table. </code></li> <li><code>WHERE ##temp1.Area <> ##temp2.Area -- The 'WHERE <>' stops a cartesian join.</code></li> <li><code>SELECT * INTO ##temp3 FROM (SELECT * FROM ##temp1 UNION SELECT * FROM ##temp2) un</code></li> <li><code>strSQL = "IF OBJECT_ID('tblTempNIS_Qtrly_SumByRUN_and_crc', 'U') IS NOT NULL DROP TABLE tblTempNIS_Qtrly_SumByRUN_and_crc" ' This is not really a temp table because no #; so must DROP. It's a helper table. Couldn't use a temp because mData's Clear lose the data for the next query's use of it. ' The ", 'U' " is optional; it just insures that the object is a user table and not, for example, a sproc or other type of object.</code></li> <li> <pre><code>'To get all information about the @@Error value that is returned in the output parameter 'From Master database 'SELECT * FROM sysmessages WHERE Error = 2627 'type value in rdoQy(3) here</code></pre> </li> <li><pre>--NWDSQL.BmrkSource.PendingPublish is empty for 2003-2004. Thus do this to populate it with rows from the other table: INSERT INTO BmrkSource.dbo.PendingPublish SELECT NEArea,IdentifierCode,EndDate,NumberOfPeople,Week,ItemCodeID,Ratio --Note: Published has 1 extra column at the end so I must list these out. FROM NELausData.dbo.Published WHERE NELausData.dbo.Published.EndDate LIKE '2004%' OR NELausData.dbo.Published.EndDate LIKE '2003%'</pre></li> </ul> <ul> <li>The INNER JOIN returns all rows from both tables where there is a match. If there are rows in first table that do not have matches in second table, those rows will not be listed. </li> <li>The LEFT JOIN returns all the rows from the first table, even if there are no matches in the second table. If there are rows in first table that do not have matches in second table, those rows also will be listed. </li> <li>The RIGHT JOIN returns all the rows from the second table, even if there are no matches in the first table. If there had been any rows in second table that did not have matches in first table, those rows also would have been listed. </li> </ul> <ul> <li><a href="http://dbazine.com/sql/sql-articles/cook1">dbazine.com/sql/sql-articles/cook1</a></li> <li><a href="http://docs.ingres.com/sqlref/SQLSTATEValuesandGenericErrorCodes">docs.ingres.com/sqlref/SQLSTATEValuesandGenericErrorCodes</a></li> </ul><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-67429187323604961652007-11-22T14:07:00.000-06:002007-11-23T21:55:07.986-06:00How to get a DB and send it....<p> You can backup the DB from the server and then restore it on your local machine with installed MS SQL Server 2000. Then you can change or delete any pruned info from the DB on your local machine. Then you can backup the modified DB again and send that backup file (*.bak file). You can send this file with Gmail. There is about 3Gb available space. </p> <ol><strong>How to backup...</strong> <li>Open Enterprise Manager</li> <li>Select source DB</li> <li>Right click on the selected DB. Select All Tasks->Backup Database... from the popup menu.</li> <li>Select File and filegroup and add destination file name in the Backup dialog.</li> <li>Press OK</li> </ol> <ol><strong>How to restore...</strong> <li>Open Enterprise Manager</li> <li>Select Databases node</li> <li>Right click on this node. Select All Tasks->Restore Database... from the popup menu.</li> <li>Type database name in the Restore as database textbox</li> <li>Select Restore From Device</li> <li>Press Select Device</li> <li>Add backup file name</li> <li>Press OK</li> <li>In the Options tab check file pathes where your database will be restored.</li> <li>Press OK</li> <li>Select File and filegroup and add destination file name in the Backup dialog.</li> <li>Press OK</li> </ol><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-61198013773628870802007-09-27T16:59:00.001-05:002007-10-12T10:57:38.948-05:00Excel: compare two Worksheets<p> <strong>Excel Macro</strong> <br/> <a href="http://exceltip.com/st/Compare_two_worksheets_using_VBA_in_Microsoft_Excel/477.html">http://exceltip.com/st/Compare_two_worksheets_using_VBA_in_Microsoft_Excel/477.html</a> <br/> Compares the 2 Worksheets and pops up a workbook with the differences: <br/> Steps: >Tools > Macro >Macros >Run </p> <p> <strong>Excel Function</strong> <br/> Function for comparing data: <a href="http://office.microsoft.com/en-us/excel/HP100625641033.aspx?pid=CH100645341033">http://office.microsoft.com/en-us/excel/HP100625641033.aspx?pid=CH100645341033</a> <br/> Here's the Excel formula: <code>=Exact(ColumnRow,ColumnRow)</code> <br/> An example: <code>=EXACT(G5,P5)</code> [First put both worksheets on the same worksheet, side by side.] <br/> If the result is True data matches; if False data does not match </p> <p> Also, I was told there is a way to recieve as output each row that was different using a "Filter".</p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-82170095343930827402007-08-30T17:37:00.001-05:002008-07-16T09:21:23.786-05:00SQL compare two tablesDifference in data stored in both tables (compare the difference between two tables)? You can use SQL to see rows which don't have a match in one table or the other: <pre><code>Select col_a,col_b from table1 where not exists (select * from table2 where table1.col_a = table2.col_a and table1.col_b = table2.col_b)</code></pre> <p> Repeat for table2. </p> <p> further notes: --http://windowsitpro.com/Articles/ArticleID/14368/14368.html?Ad=1 </br> --http://webmasterworld.com/databases_sql_mysql/3241540.htm </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-44160791962676600922007-07-20T09:30:00.000-05:002007-07-20T09:39:21.793-05:00Debug sproc in VS<p> In VS at the <strong>Sever Explorer</strong> pane I right-click on my data connection that I added and select <strong>Modify Connection</strong>. Then in the <strong>Modify Connection</strong> dialog I clicked <strong>Advanced...</strong> and then in the <strong>Advanced Properties</strong> dialog I changed <strong>Pooling</strong> from True to <strong>False</strong>. Now it works. Also, in the configuration file, the <strong>Enable SQL Server debugging</strong> must be checked. Also, I have to add <code>cmd.CommandTimeout=1800</code> to the VB's sproc area else it will time-out while clicking thru the sproc in the debugger. </p> <p> But, when not debugging, in order to get the app to run to completion without crashing with the error <strong>Error while executing 'a batch cmd' at line 0</strong> , I have to uncheck <strong>Enable SQL Server debugging</strong> and set <strong>Pooling</strong> back to <strong>True</strong>. --Because not pooling the connections hurts performance. </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-86407330760977663812007-07-18T07:56:00.000-05:002007-07-18T10:17:02.059-05:00To export DTS package, do the following:<ol style="list-style-type:arabic;"> <li>Open MS SQL Server Enterprise Manager</li> <li>Go to <strong>Local Packages</strong></li> <li>Open some DTS Package</li> <li>In the DTS Package window from menu select item <strong>Package</strong>-><strong>Save As...</strong></li> <li>In the <strong>Save DTS Package</strong> dialog <ul><li>in the <strong>Location</strong> field select <strong>Structured Storage</li> File</strong></li> <li>in the <strong>File Name</strong> field set destination path of saved file</li></ul> </li> <li>Press <strong>OK</strong> button</li></ol><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-13227143069876081202007-06-20T12:33:00.004-05:002008-03-28T20:31:34.504-05:00Server 2000: Query Analyzer Tips & TricksYou probably know that SQL Server stores metadata about all of the objects in a database. The system tables contain a wealth of information about column names, data types, identity seeds, and so on. But did you know that you can get that information with a single keystroke via Query Analyzer? Highlight the object name in any SQL statement and press Alt+F1. Figure 1 shows the results for a SQL Server table. If you don't have anything highlighted, Alt+F1 will give you information about the database itself. For an equally neat trick, highlight a SQL keyword and press Shift+F1; you'll go straight to the Books Online page that describes that keyword.<div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-58674812396424494112007-06-19T09:20:00.000-05:002007-06-19T19:56:57.438-05:00Getting .dll into Registry<ol style="list-style-type:arabic;"> <li>Download the file (MSRDO20.zip) to your desktop </li> <li>Unzip the content of the file (a file called MSRDO20.DLL) to your desktop </li> <li>Right now you should have a new file called MSRDO20.DLL that resides on your desktop </li> <li>Copy this file to your Windows System Folder; this folder is usually found inside your 'C:\Windows' folder. It is called 'C:\Windows\System' or 'System32'... </li> <li>Go to 'Start Menu' and choose 'Run' </li> <li>A new window titled 'Run' will open; type the line 'regsvr32.exe msrdo20.dll' and hit 'Enter'. </li> <li>A message will show up stating that the registration was successful. </li> </ol><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-48436006959297562362007-06-08T23:12:00.001-05:002008-07-11T12:47:03.440-05:00Visual Studio Short-cuts<p>Most of the time, you will Step Into or Step Over commands in your stored procedures. The commands below apply to a single T-SQL line:</p> <ul> <li><b>Step Into</b> (F11): Use to single step through your code. (Move the yellow arrow down one statement.)</li> <li><b>Step Over</b> (F10): Useful if you have lines of code that perhaps modify data or call other procedures that you don't care about while debugging. For example, you may want to skip code that performs auditing.</li> <li><b>Step Out</b> (SHIFT+F11): Execute the rest of the stored procedure without pause.</li> <li><b>Run to Cursor</b> (CTRL+F10): Position the cursor to a point in your code and then hit CTRL-F10 to execute all code up to that point.</li> <li><b>Continue or Start Debug or Run</b> (F5): Start Debug. Or resumes execution until completion or until the next breakpoint.</li> <li><b>Toggle Bookmark</b> (CTRL+K)</li> <li><b>Help</b> (F1)</li> </ul> <p> When you provide a summary of the class using XML comments, your class displays documentation about itself in appropriate places within Visual Studio, such as in the List Members box. Open the List Members box by selecting Edit | Intellisense | List Members from the main menu bar or by clicking the Display an Object Member List icon on the Text Editor toolbar. </p> <h2>Getting Values</h2> To see the value of your variable whilst in debug mode, use the "Command Window" (View >Other Windows >Command Window). Enter this: <code>? myVariableName</code><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-55316183030653985942007-05-17T21:53:00.001-05:002007-09-03T13:43:46.879-05:00SQL: Bulk import<p>Bulk import (save file.txt as csv): <code>LOAD DATA INFILE 'file.txt' INTO TABLE 'tblFoo' (col1, col2, col3) </code> </p> <p> or </br> <code>BULK LOAD IMPORT ('c:\file.txt') INTO TABLE 'tblFoo' (col1, col2, col3)</code> </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-51945220580059009862007-05-10T18:13:00.000-05:002007-07-18T10:22:40.181-05:00SQL Server 2000: make table backup with DTS<ul> <li>Right-click the table <ul><li>choose <strong>Export Data</strong></li> </ul> </li> <li>Choose a destination <ul><li><strong>Server:</strong> "nwdsql" and <strong>Database:</strong> NELausData</li> </ul> </li> <li> <radiobutton select="true"><strong>copy table(s)</strong></radiobutton> </li> <li> <checkbox select="true">UserXRef"_bkup" (Destination)</checkbox> </li> </ul> <p> Done, then refresh explorer to view. </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-52235142598720149182006-11-25T18:40:00.000-06:002006-11-28T20:53:18.681-06:00Install Google Search API Into Visual Studio<ul> <li>Get the Google API and unzip. Import <span style="font-family:courier new;">GoogleSearch.wsdl</span> to the Project root. </li> <li>Right-click on the Project root. <ul> <li>Add Web Reference <ul> <li> Then type in the URL: <span style="font-family:courier new;">http://localhost:1574/projectname/GoogleSearch.wsdl</span> or <span style="font-family:courier new;">http://foo.com/GoogleSearch.wsdl</span> </li> </ul> </li> </ul> </li> </ul> <p> Then you should see an <span style="font-family:courier new;">App_WebReferences</span> folder in your Project. And then a folder in that called <span style="font-family:courier new;">localhost</span>. And then files <span style="font-family:courier new;">GoogleSearch.discomap</span> and <span style="font-family:courier new;">GoogleSearch.wsdl</span> in that. </p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-63100020745144100492006-11-25T18:25:00.000-06:002007-05-17T21:50:02.914-05:00Test SQL Injection Attack on ASPUsername: <span style="font-family:arial;">foo</span><br/> Password: <span style="font-family:arial;">abc' OR 'x' = 'x</span><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.comtag:blogger.com,1999:blog-6711727.post-3586089691977795592006-11-18T20:56:00.000-06:002006-11-19T15:44:28.331-06:00Load a Control into Visual Studio<ul><li>Right-click on toolbar and "Choose Items"</li><li>Then browse and go to your /Controls/ folder</li><li>Then click on it and open</li><li>Then click "OK"</li></ul><p>Then it will be on your toolbar and there will be a Reference to it in your /Bin/</p><div class="blogger-post-footer"><script type="text/javascript"><!-- google_ad_client = "pub-4039287786711000"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "DEE7EC"; google_color_bg = "FFFFFF"; google_color_link = "0066FF"; google_color_url = "0066FF"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div>programmabilitieshttp://www.blogger.com/profile/06938880405055923257noreply@blogger.com