By default the session timeout is 20 minutes for IIS and session variables. Inorder to increase the session timeout you need to do the following changes.
<system.web>
<sessionState timeout="540" mode="InProc" /> <!-- In minutes --> </system.web>
and in the IIS seetings changes the following
1. Open Internet Services Manager.
2. From the Web site Properties, click the Home Directory tab, then click the Configuration... button in the Application Settings section.
3. On the configuration panel, click the App Options tab and set the session timeout there.
If your using form authentication then you need to do the following settings and by default the form authentication session timeout is 30 minutes.
There arefour types of temporary tables Local Temporary tables, Global Temporary Tables Permanent Tables and Tables variables.
How to declare Temporary Tables
CREATE TABLE #people
(
id INT,
name VARCHAR(32)
)
DECLARE @people TABLE
(
id INT,
name VARCHAR(32)
)
Scope
The temporary table is deleted automatically when it is goes out of the scope but you should manually drop it to use it again.
DROP TABLE #people
But in the table variable the table is dropped automatically when it goes out of the scope.
What are the difference between Temp and Table Variables
1.Table variables result in fewer recompilations of a stored procedure as compared to temporary tables.
2. You cannot use the EXEC statement or the sp_executesql stored procedure to run a dynamic SQL Server query that refers a table variable, if the table variable was created outside the EXEC statement or the sp_executesql stored procedure. Because table variables can be referenced in their local scope only, an EXEC statement and a sp_executesql stored procedure would be outside the scope of the table variable.
FYI: However, you can create the table variable and perform all processing inside the EXEC statement or the sp_executesql stored procedure because then the table variables local scope is in the EXEC statement or the sp_executesql stored procedure.
3. You use table variables whenever possible except when there is a significant volume of data and there is repeated use of the table because table variables doesnot create any indexes.
4. You cannot use a table variable in Select INTO
SELECT * INTO @table FROM someTable
5. You cannot truncate a table variable.
6. You cannot drop a table variable.
7. You cannot generate a table variable's column list dynamically, the below will throw the error
SELECT * INTO @tableVariable
8. Table variables must be referenced by an alias name when it is used in the JOINS.
SELECT id
FROM @foo f
INNER JOIN #foo
ON f.id = #foo.id
9. Table variable use fewer resource than a temporary table because of there limited scope.
10. we cannot change the definition of the table after the table is created.
11. Microsoft also say transactions involving table variables require less logging. I assume they say this because the transactions are shorter.
1. Retrieve the values from the Requirement Table.
2. Insert into the table variable.
3. Insert into the actual table by doing some processing on each record of table variable.
Structure of Table variable
DECLARE @RequirementIds TABLE ( Id INT, ReqId INT )
--Retrieve the list of requirement ids INSERT INTO @RequirementIds(Id,ReqId) SELECT Id,CAST(Data AS INT) AS ReqId FROM Requirements
-- Get the total requirement ids DECLARE @RowCount INT SET @RowCount = (SELECT COUNT(Id) FROM @RequirementIds)
-- Declare an iterator DECLARE @I INT SET @I = 1
-- Loop through the rows of a table Assets WHILE (@I <= @RowCount) BEGIN
INSERT INTO Assets
( AssetsId, ProjectID, ReqID, AssetTypeID, Title, [Description], FileSize, URL, CanVersion, [Version], [FileName], CreatedBy, DateCreated ) SELECT (Select COALESCE(Max(AssetsId),0) + 1 FROM Assets WHERE ReqID=RI.ReqId AND ProjectID=@ProjectID) AS AssetsId, @ProjectID, RI.ReqId, @AssetTypeID, @Title, @Description, @FileSize, REPLACE(@FURL,'{0}',CAST(RI.ReqId AS VARCHAR(3))) AS URL, @CanVersion, @Version, @FileName, @CreatedBy, @DateCreated FROM @RequirementIds RI WHERE Id = @I SET @I = @I + 1 END
Siva Shunmugam is a software Professional works for Effindi Technologies. He loves technology because it makes the life easy and likes socializing. By beeing a professional he comes to know about how the technology is beeing handled in the real time world. Among the many technological programes he uses and embraces SQL-SERVER, ASP.NET, JQUERY simply because he uses it in his profession.
DISCLAIMER
This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet/ BOL. My employer do not endorse any tools, applications, books, or concepts mentioned on the blog. I have documented my personal experience on this blog.