Posts

Showing posts from June, 2010

Tables in SQL Server

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I’ll discuss the differences between using temporary tables in SQL Server versus table variables. Each of the four table options has its own purpose and use, and each has its benefits and issues: * Normal tables are exactly that, physical tables defined in your database. * Local temporary tables are temporary tables that are available only to the session that created them. These tables are automatically destroyed at the termination of the procedure or session that created them. * Global temporary tables are temporary tables that are available to all sessions and all users. They are dropped automatically when the last session using the temporary table has completed. Both local temporary tables and global temporary tables are physical tables c

Alternatives to @@IDENTITY

@@IDENTITY on a connection regardless of the table regardless of the scope IDENT_CURRENT( ' tablename ' ) Regardless of the connection produced in a table regardless of the scope SELECT SCOPE_IDENTITY() produced on a connection regardless of the table in the same scope SELECT @@IDENTITY It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value. @@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it. SELECT SCOPE_IDENTITY()

Two Interceptors: HttpModule and HttpHandlers-downloading a file

Image
Introduction Many times we want to implement pre-processing logic before a request hits the IIS resources. For instance you would like to apply security mechanism, URL rewriting, filter something in the request, etc. ASP.NET has provided two types of interception HttpModule and HttpHandler . This article walks through it. The Problem Many times we need to inject some kind of logic before the page is requested. Some of the commonly used pre-processing logics are stat counters, URL rewriting, authentication / authorization and many more. We can do this in the code behind but then that can lead to lot of complication and tangled code. The code behind will not solve the purpose because in some implementations like authorization, we want the logic to execute before it reaches the resource. ASP.NET provides two ways of injecting logic in the request pipeline HttpHandlers and HttpModules . HttpHandler - The Extension Based Preprocessor HttpHandler help us to inject pre-proces

50 Common Interview Questions and Answers :

Review these typical interview questions and think about how you would answer them. Read the questions listed; you will also find some strategy suggestions with it. 1. Tell me about yourself: The most often asked question in interviews. You need to have a short statement prepared in your mind. Be careful that it does not sound rehearsed. Limit it to work-related items unless instructed otherwise. Talk about things you have done and jobs you have held that relate to the position you are interviewing for. Start with the item farthest back and work up to the present. 2. Why did you leave your last job? Stay positive regardless of the circumstances. Never refer to a major problem with management and never speak ill of supervisors, co- workers or the organization. If you do, you will be the one looking bad. Keep smiling and talk about leaving for a positive reason such as an opportunity, a chance to do something special or other forward- looking reasons. 3. What experien

cursors status

1 Find out the cursors that are allocated but not opened or closed view source print ? 01. --Method 1 02. 03. select name from sys.dm_exec_cursors(0) where is_open =0 04. 05. 06. --Method 2 07. 08. select 09. cur.cursor_name 10. from 11. sys.syscursorrefs as ref inner join sys.syscursors as cur on ref.cursor_handl=cur.cursor_handle 12. where 13. cur.open_status =0 2 Find out the cursors that are opened and not closed view source print ? 01. --Method 1 02. 03. select name from sys.dm_exec_cursors(0) where is_open =1 04. 05. 06. --Method 2 07. 08. select 09. cur.cursor_name 10. from 11. sys.syscursorrefs as ref inner join sys.syscursors as cur on ref.cursor_handl=cur.cursor_handle 12. where 13. cur.open_status =1 3 Find out the cursors that are allocated but not deallocated 01. --Method 1 02. 03. select name from sys.dm_exec_cursors(0) 04. 05. 06. --Method 2 07. 08. select 09. cur.cursor_name