Solved

Vistual Studio DataSet Table Adapter Does not recognize temporary tables

Posted on 2013-12-17
3
418 Views
Last Modified: 2014-01-14
I am using temporary tables on my stored procedure using #tableName. The stored procedure will run ok but when I connect Stored proc to Visual Studio project, cannot create dataset. It does not recoginze stored proc due to #tableName invalid object name.
0
Comment
Question by:ocdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Expert Comment

by:HuaMinChen
ID: 39726081
You can instead use a normal table name, like
create table tab1 ...

Open in new window


and drop it at the end of SP.
0
 
LVL 15

Expert Comment

by:JimFive
ID: 39727031
Are you seeing the error in the design studio or are you getting an error when you execute?
0
 
LVL 20

Accepted Solution

by:
Marten Rune earned 500 total points
ID: 39727248
Are you using Another session. If so you need a global temp table.

Quote:"SQL Server allows you to create temporary tables that hold data temporarily. Local temporary tables (using one #) hold data until the session is closed and global temporary tables (using two #) hold data until all existing sessions are closed."
From: http://social.technet.microsoft.com/Forums/lync/en-US/7c70106b-f621-4e4d-a91f-100a571e9dee/equivalent-of-on-commit-preserve-rows-in-sql?forum=transactsql

You can start by checking if the temptable exists and if it does take an action f x drop it as:
if OBJECT_ID('tempdb..#test') is not null
Drop table #test

Regards Marten
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question