Posts

Showing posts from 2012

Auto generate change scripts in SQL Server Management Studio SSMS for tables

Image
Problem As a part of my best practices, I always save the T-SQL scripts used for creation and modification of objects in SQL Server. When creating and modifying tables using SQL Server Management Studio designer it is easy to right click in the designer and select "Generate Change Script...", but is there a way to automatically script the creation and/or modification of tables made through of SQL Server Management Studio (SSMS) designer?  This tip shows you an option that exists within SSMS to automatically generate these scripts for all table changes when using the table designer. Solution Within SQL Server Management Studio (SSMS) there is an option to automatically generate scripts for your changes done through the GUI.  The solution for this problem is provided in SSMS and works with both SQL Server 2005 and SQL Server 2008, but by default this option that we will discuss is disabled. To enable the option From the SSMS menus click on "Tools"  ...

Visual Studio 2008, 2010, 2011, 2012 Keyboard Shortcuts Keys

It is amazing that you can get around without using a mouse at all. Master the following Visual Studio shortcuts and your colleagues might stare at you with amazement. 1.    F5: Start your project in debug mode 2.    F7 & Shift-F7: Show the code windows & Show the designer window 3.    Alt-Enter: Show the properties panel for a selected object (this is general Windows shortcut that can be used on files and directories) 4.    F6 / Shift-F6 / Ctrl-Shift-B: Build solution / Build project / Build solution 5.    Shift-Alt-C: Add a new class to your project 6.    Ctrl-K + Ctrl-C: Comment a selected block of code 7.    Ctrl-K + Ctrl-U: Un-comment a selected block of code 8.    Ctrl-M + Ctrl-O / Ctrl-M + Ctrl-P: Collapse all code to definitions / Expand all code (stop collapsing) 9.    Ctrl-M + Ctrl+M: Expend or collapse a selected code fragment. T...

What is a trusted connection?

Net-Lib (The Microsoft SQL Server Network Library) is also able to support the impersonation of a logged in user's security context for protocols that support authenticated connections (called trusted connections). This allows Net-Lib to provide an integrated logon authentication mechanism via the use of Windows Authentication. Windows Authentication is not supported on Windows 98 or Windows Me.

how to subtract value at previous row from current row?

Table data is like....  ------------------------------ EmpID    Emp_Name    Salary ------------------------------- 1             Mark             4000 2             Twin              2000 3             Aleganja        3000 4             Peter             8000 ------------------------------- Method (1) ------------------------------------ -  select top 1 EmpID,SALARY from Employee  union  SELECT e1.EmpID,(e2.Salary - e1.Salary) AS SALARY FROM Employee e1  INNER JOIN ...

End Date should not be less than Start Date using jQuery Date Picker

set maxDate: '0d' if you want to set your range with current date. $(document).ready(function(){ $("#txtFromDate").datepicker({ maxDate: '0d', numberOfMonths: 2, onSelect: function(selected) { $("#txtToDate").datepicker("option","minDate", selected) } }); $("#txtToDate").datepicker({  maxDate: '0d', numberOfMonths: 2, onSelect: function(selected) { $("#txtFromDate").datepicker("option","maxDate", selected) } }); });

How can I get column names from a table in sql server?

SELECT [name] FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE type = 'U' AND [Name] = 'Your Table Name')

C# Remove HTML/XML Tags

Removing HTML tags from strings Input: <p>The <b>dog</b> is <i>cute</i>.</p> Output: The dog is cute. Performance test for HTML removal HtmlRemoval.StripTagsRegex: 2404 ms HtmlRemoval.StripTagsRegexCompiled: 1366 ms HtmlRemoval.StripTagsCharArray: 287 ms [fastest] File length test for HTML removal File tested: Real-world HTML file File length before: 8085 chars HtmlRemoval.StripTagsRegex: 4382 chars HtmlRemoval.StripTagsRegexCompiled: 4382 chars HtmlRemoval.StripTagsCharArray: 4382 chars HtmlRemoval static class [C#] using System; using System.Text.RegularExpressions; /// <summary> /// Methods to remove HTML from strings. /// </summary> public static class HtmlRemoval { /// <summary> /// Remove HTML from string with Regex. /// </summary> public static string StripTagsRegex(string source) { return Regex.Replace(so...

Working with Power Builder Data Window

1) create a custom object with  n_Connection  name and class with  GetConn and   return as transcation data type... // Profile myprofile Transaction trans SQLCA.DBMS = "SNC SQL Native Client(OLE DB)" SQLCA.LogPass = "**************" SQLCA.ServerName = "000.000.000.000" SQLCA.LogId = "User ID" SQLCA.AutoCommit = False SQLCA.DBParm = "Database='Database Name',Provider='SQLNCLI10',TrustedConnection=1" connect using sqlca; trans=sqlca return trans 2) Bind Data window... n_Connection obj obj = create n_Connection Transaction tran tran  = create Transaction tran=obj.GetConn() connect using tran; datawindow .SetTransObject(tran) datawindow .Retrieve() disconnect using tran; 3) Update record after change data in grid itself... n_Connection obj obj = create n_Connection Transaction tran tran  = create Transaction tran=obj.GetConn() connect using tran; datawindow.SetTransObject(tran) datawindow ...

What is Magic table in SQL ?

Magic tables are nothing but INSERTED, DELETED table scope level, These are not physical tables, only Internal tables.  This Magic table are used In SQL Server 6.5, 7.0 & 2000 versions with Triggers only.  But, In SQL Server 2005, 2008 & 2008 R2 Versions can use these Magic tables with Triggers and Non-Triggers also.  Using with Triggers:   If you have implemented any trigger for any Tables then,  1.Whenever you Insert a record on that table, That record will be there on INSERTED Magic table.  2.Whenever you Update the record on that table, That existing record will be there on DELETED Magic table and modified New data with be there in INSERTED Magic table.  3.Whenever you Delete the record on that table, That record will be there on DELETED Magic table Only.  These magic table are used inside the Triggers for tracking the data transaction.  Using Non-Triggers:  You can also use the Magic tables with Non-Trigger activities using...

Verify Whether a SQL Server Agent Job is Running

DECLARE @jobname sysname ='Running Job' -- Enter the job name here SET NOCOUNT ON IF NOT EXISTS (SELECT * FROM msdb..sysjobs Where Name = @jobname) BEGIN PRINT 'Job does not exists' END ELSE BEGIN CREATE TABLE #xp_results ( 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_jo...

CSS3 GENERATOR

http://www.webtutorialplus.com

Automatic link source in your every copy paste text.

Add this script in your master page/page and change text " Your Site Name " with your website name and enjoy.  <script type="text/javascript">         function addLink() {             var body_element = document.getElementsByTagName('body')[0]; var selection;             selection = window.getSelection();             var pagelink = "<br /><br /> Read more at: <a href='" + document.location.href + "'>" + document.location.href + "</a><br />Copyright &copy; Your Site Name";             var copytext = selection + pagelink; var newdiv = document.createElement('div'); newdiv.style.position = 'absolute'; newdiv.style.left = '-99999px'; body_element.appendChild(newdiv); newdiv.innerHTML = copytext; selection.selectAllChildren(newdiv); window.setTimeout(function () { body_element.removeChild(newdiv); }, 0...

Human Blood Type Chart

Human Blood Type Chart A, B, AB or O ABO Blood Type Per Cent of General Population Can DONATE Red Cells To: Can RECEIVE Red Cells From: Chance of Finding A Compatible Donor O+ 38.5% O+, A+, B+, AB+ O+, O- 1 out of 2 50% O- 6.5% All Types (universal donor) O- 1 out of 15 7% A+ 34.3% A+, AB+ A+, A-, O+, O- 4 out of 5 80% A- 5.7% A-, A+, AB-, AB+ A-, O- 1 out of 8 13% B+ 8.6% B+, AB+ B+, B-, O+, O- 3 out of 5 60% B- 1.7% B-, B+, AB-, AB+ B-, O- 1 out of 12 9% AB+ 4.3% AB+ All Types (universal recipient)  100% AB...

ASP.NET Page Life Cycle Overview

Image
Page Life-Cycle Stages Page request  The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. Start   In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property. Initialization  During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state. Load  During load, if th...