create procedure proc1 (@a int)
as
begin
if @a=1
create table #temp(a1 int)
else
create table #temp(a1 int)
end
while executeing the above code it shows error
like '#temp already exist' .why it shows an error?
Answer Posted / murthy
The #Temp table created in this stores procedure exists in
memory as long as the Particular session is closed. Hence
drop the table at the end of the procedure.
Note: In case if you exec the SP using Management studio,
close the connection and re-open it, it will work without
modifying anything.
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
How to receive output values from stored procedures?
What is the difference between a "where" clause and a "having" clause?
What is NOT NULL Constraint in sql server 2012?
What is difference between sql and sql server?
Tell me what is the stuff and how does it differ from the replace function?
Where are SQL server users names and passwords are stored in sql server?
How do you create a data source?
What are the different types of upgrades that can be performed in sql server?
You have several tables, and they are joined together for querying. The tables contain both clustered indexes and non clustered indexes to optimize performance, how should you distribute the tables and their indexes onto different file groups?
What is difference between index and primary key?
How you can change a cross join into an inner join?
This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?
what is a transaction and what are acid properties? : Sql server database administration
Where does the copy job runs in the log shipping primary or secondary? : sql server database administration
Do you know the cursor types?