.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

temp tables!

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :Sql Server

hi friend,

assume i have created a temp table, #t1 and after completion of query execution in the sp i can delete it from db.

in multi user enviorement, each user who acess that sp creates a temp table, i know teml tables has a structre #_______________<number>  so when each user access this sp, does it create a seperate temp table for each call?



View Complete Post

More Related Resource Links

creating temp tables!

hi friends, 1. Is the tempdb in teh SQL server (2005) is a global database that is shared among other user defined databases? 2. Is is possible to create User defined temp databases like tempdb and how? i have create a temp table create table #usr_with_rls (idx int primary key, usr_name nvarchar(50), f_name nvarchar(50), l_name nvarchar(50), desig nvarchar(50)) and it was created in the tempdb database.  but the sp that creates the this table is in another database, therefore 3. How do i create this temp table "urs_with_rls" in my datbase and not in the tempdb? 4. I need to remove this temp datanase "urs_with_rls" from the server, onces teh sp completes it execution, how do i do that? thanks    

use temp tables instead of CTE's


I need to re write this query with CTE's to reflect differences in DNC ($$) between my @mindt and @maxdt

do I need to show a DNC @ MIN Date and DNC @ Max DT so i can calculate the differerence...can you help?

declare @mindt datetime
declare @maxdt datetime

set @maxdt = getdate()
set @mindt = getdate()-14;

With itmlvl as (



select RB.RBT_TYP_ID
	, rb.DSCR, rp.AMT
	, splr.EM_ITEM_NUM

from geprs_dnc..t_rebate rb 

Staging vs Temp tables in SSIS

Hi SSIS Guru,

Currently, we have our own internal app to pull data from the internet nightly to serverA. On serverA, there is a huge stored precedure doing update, insert and delete by joining lots of tables on serverB via synonyms over LINKED SERVER. However, there are only 3-4 tables on serverA used to join tables on serverB.

I am rewritting this process to eliminate linked server and use SSIS instead of stored procedure. What is the best option to bring tables from serverA to serverB? Should I create staging tables on serverB and refresh tables with TRUNCATE or use temp table instead?

Thanks much,
Staging vs Temp tables in SSIS

How to take the scripts of the changed SPs/Views/Temp tables/Functions automatically?



  We have a huge Database with more than 100 tables , more than 150 SPs.We are 10 members and we will be creating/deleting/updating SPs , functions, views, tem tables  everyday. Actually at the end of the day, we have to send the  scripts of latest SPs,functions,views,Temp tables to the server. So far what we are doing is  we manually go to the SQL server Scripts Wizard and selecting one by one all the SPs,functions,TTables and views. Is there any quicker way to take the changed stuffs instead going manually?

Better performance when all temp tables are at start of proc - STILL DON'T SEE WHY


I've already posted on this:


and was convinced even more by what was written in:



BUT when I actually tested a simple script with a profiler there was no difference in the number of deferred compiles (which is two) when all tables were at the start and when tables were spread in the procedure (According to the theory the second stored proc below should have produced only one deferred compile). This script completely contradicts the technical page link above. How can it be explained?




Can I have 3 different tables in a report? And, can I pass 3 temp table to SSRS as source for these

I'm using BI 2008 and sql 2005 and 2008.  Is there an example to show me?  Thanks.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Temporary Tables - MS SQL Server

Usage of temporary tables in MS SQL Server is more developer friendly and they are widely used in development. Local temporary tables are visible only in current session while global temporary tables are visible across all sessions.

Temporary tables in SQL Server vs. table variables

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.

Using a trigger or anything else to populate two tables


Hi! I'm creating an application that's supposed to first add a record to table1, and then get the ID from that record to use when adding a record to table2, to be able to associate these two records with eachother.

The user gets to type in some values that goes to table1, and some values that goes to table2, but before the insert statement for table2 is executed i need the ID from the recently added record in table1. Some dude told me to use a trigger for the autopopulate purpose, but does that really work when i also need to save some values that's user input, and when those values doesn't get saved in table1?

Are there any other way to do this or can i send values to a trigger? I'm new to triggers and stored procedures, i don't have any particular knowledge of this, any help is appreciated!


Regards, Monsterbadboll

merging multiple tables in a single dataset to single table


 i have a stored procedure which returns three tables to a dataset ..... now i need to merge all three tables to a single table from d same dataset 

like dataset1 has table1 table2 and table3 .... i want all the three tabels to be merged into dataset1 itself .... instead of three diffrent tables so that i can show all three table data in a single datagrid  as a compact data and combination of 3 tables from d single dataset.....

can some1 help me please.....

SqlDataSource UpdateCommand using 2 tables


I have two tables

Trans  with fields TransID, Date, CustomerID and some other stuff

Customer with fields CustomerID, Name, TaxId

On the screen the user only sees the fields Date and Customer Name. CustomerID is behind the scenes only.


I'm using SqlDataSource. Having no problems with SelectCommand. I don't know how to construct the UpdateCommand and InsertCommand.

Let's say the user changes the date, then I need to do an UPDATE.

UPDATE Trans SET Date = @Date, CustomerID = @CustomerID results in an error message and the record is not updated.

I get an error on the page that says "Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in correct format".


I tried taking out the set for CustomerID and I still get the error on page.


Also, for inserting, the users will see a dropdownlist with Customer Names. I need to convert that to a CustomerID to be used in the new record being inserted in the database. I'm not sure how to do this.


Do I need to do something with Control Parameters?

How to display related tables in one crystal report and how to link this report with combobox?


Hi! I want to display a crystal report in my vb.net application. Suppose I have tables named student details, student marks, student address, etc... Now if I want to display all these details (fields of all tables) in one crystal report (with page breaks if necessary) then how will I achieve it. I will be providing a combo box in my application that contains list of student names. How can I link this combo box with the cystal report to dynamically display report for different student on selected index change of combo box? Help me friends. An example would be appreciable.

Data Points: Creating Audit Tables, Invoking COM Objects, and More


Dealing with error handling between T-SQL and a calling application, evaluating when a field's value has changed, and creating auditing tables in SQL ServerT are all common issues that developers must tackle.

John Papa

MSDN Magazine April 2004

Sql Scripts - Delete all Tables, Procedures, Views and Functions


In a shared environment you typically don't have access to delete your database, and recreate it for fresh installs of your product. 

I managed to find these scripts which should help you clean out your database.

Use at your own risk.


Delete All Tables

--Delete All Keys


Join Two Tables and Prepare Report



            I have a select query which is executing well. Now, I want to add one more field to that query. That field is not in the current query table, It is in the another table.

How do I join those two tables and get that field value in the existing select query.?


Migrating aspnet tables to dev server - having issues



We're trying to migrate a one of our apps to our dev server for testing and development, but we're having problems with the membership functionality. We can add users, but there seems to be a disconnect with roles. We can query the aspnet_users table and find the new user in there, but when we query the aspnet_usersinroles table, that user id is not present.

We're also unable to run the Roles.GetUsersInRole("somerole") method. It returns 0 records. When I run Roles.ApplicationName, it returns the correct name, so .NET should be passing the correct app name.

We're just a little baffled. If anyone could shed some light on what could be the issue, we would appreciate it.

Thanks! :)

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend