Skip to main content

Posts

Reading Transaction Log in SQL

If you are using SQL Server 6.5 you could query the system table SYSLOGS, by using the following statement: SELECT xactid AS TRAN_ID, CASE op WHEN 0 THEN 'BEGINXACT Start Transaction' WHEN 1 THEN 'Sysindexes Change' WHEN 2 THEN 'Not Used' WHEN 3 THEN 'Not Used' WHEN 4 THEN 'INSERT Insert Row' WHEN 5 THEN 'DELETE Delete Row' WHEN 6 THEN 'INSIND Deferred Update step 2 insert record' WHEN 7 THEN 'IINSERT NC Index Insert' WHEN 8 THEN 'IDELETE NC Index Delete' WHEN 9 THEN 'MODIFY Modify Row' WHEN 10 THEN 'NOOP' WHEN 11 THEN 'INOOP Deferred Update step 1 insert record' WHEN 12 THEN 'DNOOP Deferred Update step 1 delete record' WHEN 13 THEN 'ALLOC Allocate Page' WHEN 14 THEN 'DBNEXTID Allocate Next Object ID' WHEN 15 THEN 'EXTENT Allocate Empty Extent' WHEN 16 THEN 'SPLIT Page split' WHEN 17 THEN 'CHECKPOINT' WHEN 18 THEN 'SAV...

JavaScript Interview Questions

This is a compilations of all the interview questions related to Javascript that i have encountered.  Q: Difference between window.onload and onDocumentReady? A: The onload event does not fire until every last piece of the page is loaded, this includes css and images, which means there’s a huge delay before any code is executed. That isnt what we want. We just want to wait until the DOM is loaded and is able to be manipulated. onDocumentReady allows the programmer to do that. Q:  What is the difference between == and === ? A: The == checks for value equality, but === checks for both type and value. Few examples: "1" == 1; // value evaluation only, yields true "1" === 1; // value and type evaluation, yields false "1" == true; // "1" as boolean is true, value evaluation only, yields true "1" === false; // value and type evaluation, yields false Q: What does “1″+2+5 evaluate to? What about 5 + 2 +...

Javascript - Points to Remember

What is it? Client-Side Scripting Language (we send the code to the client and let them run it) Asp.Net is sever side Developed by Sun Microsystem Programming Language of the web that adds interactivity to the pages Only works inside a web browser to manipulate web pages. Cannot be used in windows application. Does not have access to file system, database, usb port jquery - 3rd party javascript library . provide excellent cross browser functions (Microsoft product) web pages have the following 3 core languages html - content eg: what needs to be displayed and how css - presentation eg: background color, font javascript - behavior (interactivity) eg: wht happens on mouse click EcmaScript 3 - 1999 has full support on IE, Firefox, chrome, opera, safari Where to put the javascript: Inline In Script tag                   In another file    ...

Cross Join or comma separated tables

In SQL cross join returns the Cartesian product of all tables involved in the join.  For two tables, the resulting number of rows returned equals the number of rows in the first table times the number of rows in the second table. It  can be written using one of the two syntax: SELECT  A.COLUMN1 , B.COLUMN1 , C.COLUMN1  FROM TABLE1 A ,  TABLE1 B  ,  TABLE1 C OR SELECT  A.COLUMN1 , B.COLUMN1 , C.COLUMN1  FROM TABLE1 A   CROSS JOIN TABLE1 B  CROSS JOIN TABLE1 C

SQL Server 2008 - Inline Variable Assignment

Microsoft SQL Server 2008 brings in a new feature of 'Declaring and Assigning' a variable all in a single line. Earlier, while using SQL 2005 and earlier versions, we had to declare a variable before assigning it. This feature is explained in detail below. In SQL 2005 and earlier versions we had to write: Declare @age int Declare @name nvarchar(25) Declare @date date Set @age = 25 Set @name = "Garry" Set @date = GETDATE() With SQL 2008 we can combine both these statements to write Declare @age int = 25 Declare @name nvarchar(25) Declare @date @date = GETDATE() Advantage : This helps us to write less code, yet get the same functionality. Even though this feature has been available it is not being used in many projects because of backward compatibility issue. If the same code is being used on both 2005 and 2008 server we would prefer writing in a format compatible to both. Do share with us :  Would you like to use this new method? If not, why?

WPF Step by Step

.Net 3.0 introduced a whole new bunch of things. WPF - Windows Presentation Fountdation WCF - Windows Communication Foundation WF - Windows Workflow Engine Windows Cardspace.  Few months back when I started learning WPF I faced a lot of difficultly as there are so many resources on WPF and nothing takes you through step by step way to learn WPF. I thought of sharing some of the great sites / videos with you all. WPF Soup to Nuts (Eighteen Part Series) by Bill Steele Part 1. Introduction Part 2. What Is the Extensible Application Markup Language? Part 3 : searching the link... sorry about that Part 4. Hello World In case you like learning from a book - Windows Presentation Foundation Unleashed (link below) is a great book. This is my small attempt to create a guide for WPF learners. I will really appreciate it, if you could share some comments or good links to benefit WPF learners

Do's and Don't SQL

Do's: Writing comments whenever something is not very obvious, as it won’t impact the performance.  (--) for single line  (/*…*/) to mark a section Use proper indentation Use Upper Case for all SQL keywords. SELECT, UPDATE, INSERT, WHERE, INNER JOIN, AND, OR, LIKE. Use BEGIN... END block for multiple statements in conditional code  Use Declare and Set in beginning of Stored procedure Create objects in same database where its relevant table exists otherwise it will reduce network performance. Use PRIMARY key in WHERE condition of UPDATE or DELETE statements as this will avoid error possibilities. If User table references Employee table than the column name used in reference should be UserID where User is table name and ID primary column of User table and UserID is reference column of Employee table. Use select column name instead of select * Use CTE (Common Table Expression); its scope is limited to the next statement in SQL query, instead of...

Stored Procedure or In-line code?

I was reviewing this application created by my colleague and was wondering, do we need a stored procedure for single insert statements. Could this be not written directly in the code? First, let me tell you what is a Stored Procedure is. A Stored Procedure is a group of Transact-SQL statements (DDL & DML) compiled into a single execution plan. It contain programming statements that perform operations in the database, including calling other procedures. A proc can accept input parameters and return multiple values in the form of output parameters to the calling procedure or batch. There are various advantages of a stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, or SP) over inline code. The most important being 'Security' and 'Speed'. Compilation and storing of the query execution plan - Increases Speed & Reduces Network Traffic When SQL Server runs a query it calculates the most efficient method of processing the query and stores it in s...

Data DeDuping!

Data deduplication, often called "intelligent compression" or "single-instance storage", is a process that uses matching logic to eliminate file records that are duplicates (dupes). It is a method of reducing storage needs by eliminating redundant data and replacing it with a pointer to the unique data copy Data deduplication offers other benefits. Lower storage space requirements will save money on disk expenditures. The more efficient use of disk space also allows for longer disk retention periods, which provides better recovery time objectives (RTO) for a longer time and reduces the need for tape backups. Data deduplication also reduces the data that must be sent across a WAN for remote backups, replication, and disaster recovery. Deduping is a 3 step process Step 1: Move the non duplicates (unique tuples) into a temporary table SELECT * into new_table FROM old_table WHERE 1 GROUP BY [column to remove duplicates by]; Step 2: Delete the old table. We no ...

Create Database and Tabe

Create Database CREATE DATABASE  -----> syntax *****you can use the CREATE statement only to create objects onthe local server CREATE DATABASE [ON [PRIMARY] ([NAME = <’logical file name’>,] FILENAME = <’file name’> [, SIZE = ] [, MAXSIZE = size in kilobytes, megabytes, gigabytes, or terabytes>] [, FILEGROWTH = ])] [LOG ON ([NAME = <’logical file name’>,] FILENAME = <’file name’> [, SIZE = ] [, MAXSIZE = size in kilobytes, megabytes, gigabytes, or terabytes>] [, FILEGROWTH = ])] [ COLLATE ] [ FOR ATTACH [WITH ]| FOR ATTACH_REBUILD_LOG| WITH DB_CHAINING ON|OFF | TRUSTWORTHY ON|OFF] [AS SNAPSHOT OF ] [;] CREATE DATABASE Accounting ON (NAME = ‘Accounting’, FILENAME = ‘c:\Program Files\Microsoft SQL Server\ MSSQL.1\mssql\data\AccountingData.mdf’, SIZE = 10, MAXSIZE = 50, FILEGROWTH = 5) LOG ON (NAME = ‘AccountingLog’, FILENAME = ‘c:\Program Files\Microsoft SQL Server\ MSSQL.1\mssql\data\AccountingLog.ldf’, SIZE = 5...

Bytes to TeraBytes.

Converting from bytes to terabytes is very easy considering that terabyte = 1024*Gigabyte              = 1024 * 1024 * Megabyte              = 1024 * 1024 * 1024 KiloByte              = 1024 * 1024 * 1024 * 1024 * Byte Query below gives number of documents in a media and the total size of the documents. See how you have used Alias in the query SELECT        [MEDIA] = X.media_id,         [TOTAL] = COUNT(*),       [Size_KB] = SUM (Size_MB) FROM       (       SELECT              d.edoc_id,              d.media_id ,             SIZE_MB =  (                         CAST(ISNULL(d.Size1,0) AS DECIMAL) +      ...

SQL data storing options

In SQL we have four different ways to "store" data in a table: local temporary tables (#table_name), global temporary tables (##table_name), permanent tables (table_name), table variables (@table_name).   Local Temporary Tables CREATE TABLE #people ( id INT, name VARCHAR(25) )   A temporary table is created and populated on disk, in the system database tempdb — with a session-specific identifier packed onto the name, to differentiate between similarly-named #temp tables created from other sessions. The data in this #temp table (in fact, the table itself) is visible only to the current scope (usually a stored procedure, or a set of nested stored procedures). The table gets cleared up automatically when the current procedure goes out of scope, but you should manually clean up the data when you're done with it:   DROP TABLE #people   This will be better on resources ("release early") than if you let the system clean up *after* the current session finishes the r...

.Net Vocabulary

ASP.NET: Server side technology ( code is interpreted by the web server ) for developing web applications based on Microsoft .Net Framework IDE : Integrated Development Environment Web Client: A program that is used to interact with the web application eg: Internet Explorer, Firefox

OOPs...

OOPs or Object Oriented Programming is an approach that puts object at the center of programming model. An object is a self contained entity that has a state and behaviour. State is described by fields and properties, while behavior is defined by methods and events. Object is an instance of a class.  A class acts like a blueprint for the object . It defines behavior of object of that type.So all objects of type Vehicle will have the same behavior. Vehicle class will have the properties - 'color' , 'weight', 'model', 'make' . Properties are characteristic shared by all objects of a particular class.  Methods are actions of an object - 'start', 'stop' Constructors are special kinds of methods, used to initialize objects. It executes automatically when a class is instantiated Access modifies helps in controlling the visibilty of a class. * Public allows the property or methods to be called outside the class * Private fields and ...

ASP.NET Basics

ASP.NET is a server side technology for developing web based applications based on Microsoft .Net  Framework. ASP.NET is run on the web server. When a user click on a page/website link on a web browser, a request is sent to the web server. The web server reads the code and generates a web page . The web page is then sent to the browser where the client reads this page. Since the processing is on the server, it is called 'Server Side technology'. Features of ASP.NET: It lets you write server side code using over 40 languages. Most popular being C# and VB ASP.NET pages are compiled, not interpreted It has full access to the functionality  of .Net Framework... XML, web services, database interaction, emails, regular expression You can separate server side code of your page from HTML layout Easy to reuse common User Interface elements An ASP.NET page generally consists of the following: 1. Directive: Controls how page is compiles , how page is cached by web browser, err...

FxCop - The .Net Assembly COP

FxCop (Framework Police) is a free code analysis tool provided by Microsoft basically intended for class library developers. It is a must have tool for new developers who want help in getting familiarized with  Microsoft Design Guidelines. FxCop helps to write robust code and easily maintain code by telling you about the possible design, localization, performance and security improvements. It can prevent flaws in the code and helps the programmer to follow best practices. FxCop is fully integrated in the Visual Studio and is distributed as both a fully featured application that has a graphical user interface (FxCop.exe) for interactive work, and a command-line tool (FxCopCmd.exe) suited for use as part of automated build processes or integrated with Microsoft Visual Studio® .NET as an external tool. It analyses Binary Common Intermediate Language (CIL) instead of the source code, it is not language specific tool and can be used for analysing a dll written in any programming langu...

Why ' set ANSI_NULL ON ' while writing SP

-- Create table t1 and insert values. CREATE TABLE t1 (a INT NULL) INSERT INTO t1 values (NULL) INSERT INTO t1 values (0) INSERT INTO t1 values (1) GO When SET ANSI_NULLS is ON, all comparisons against a null value evaluate to UNKNOWN.  -- SET ANSI_NULLS to ON and test. SET ANSI_NULLS ON GO DECLARE @varname int =  NULL SELECT * FROM t1  WHERE a = @varname  -- No output SELECT * FROM t1  WHERE a <> @varname -- No output SELECT * FROM t1  WHERE a IS NULL     -- NULL  GO When SET ANSI_NULLS is OFF, comparisons of all data against a null value evaluate to TRUE if the data value is NULL -- SET ANSI_NULLS to OFF and test. SET ANSI_NULLS OFF  GO DECLARE @varname int =  NULL SELECT * FROM t1  WHERE a = @varname  -- NULL SELECT * FROM t1  WHERE a <> @varname -- 0 , 1 SELECT * FROM t1  WHERE a IS NULL     -- NULL  GO -- Drop table t1. DROP TABLE t1

Resolve conflicting changes in a shared workbook

Sharing Made Easy continued... When you are sharing something conflicts are bound to happen. A conflict happens when two users are both editing the same shared workbook and try to save changes that affect the same cell. Excel can keep only one of the changes in that cell. When the second user saves the workbook, Excel displays the RESOLVE CONFLICTS dialog box. 1. In the RESOLVE CONFLICTS dialog box, read the information about each change and the conflicting changes made by the other user. 2. To keep your change or the other person's change and to advance to the next conflicting change, click ACCEPT MINE or ACCEPT OTHER. To keep all of your remaining changes or all of the other user's changes, click ACCEPT ALL MINE or ACCEPT ALL OTHERS. To override resolve conflicts dialog To have your changes override all other changes without displaying the RESOLVE CONFLICTS dialog box again,: click SHARE WORKBOOK. On the ADVANCED tab, under CONFLICTING CHANGES BETWEEN USERS, cli...

Sharing Made Easy - Excel

Its extremely easy to create a workbook and place it on a network location where several people can edit the contents simultaneously. For example, if the people in your work group each handle several projects and need to know the status of each other's projects, the group can use a shared workbook to track the status of the projects. All persons involved can then enter the information for their projects in the same workbook. As the owner of the shared workbook, you can manage it by removing users from the shared workbook and resolving conflicting changes. When all changes have been incorporated, you can stop sharing the workbook. Share A Workbook Not all features are supported in a shared workbook. If you want to include any of the following features, you should add them before you save the workbook as a shared workbook: merged conditional formats data validation, charts, pictures, objects including drawing objects, hyperlinks scenarios, outlines subtotals, data tables PivotTa...

T-SQL Conditional looping....WHILE

Conditional Looping means executing the same code again and again, as long as the specified condition is true. 'WHILE' statement helps in executing a statement or a block of statement repeatedly, till the specified condition(s) is true. The number of times depends on the condition statement writen after the 'WHILE' keyword. The execution of statements in the WHILE loop can be controlled from inside the loop with the BREAK and CONTINUE keywords. Break causes an exit from the innermost WHILE loop. Any statements that appear after the END keyword, marking the end of the loop, are executed.  CONTINUE  causes the WHILE loop to restart, ignoring any statements after the CONTINUE keyword. Syntax for WHILE WHILE ( Boolean_expression )    BEGIN    'Sql Statement Block'    END Simple WHILE Example    WHILE (x>y)        BEGIN        SELECT 'If x is greater than y, this statement ...