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
Solved

SQL SERVER MANAGEMENT STUDIO: Create Table in Stored Procedure and view in object brower

Posted on 2007-03-27
12
737 Views
Last Modified: 2008-06-28
Hello,

How do I create a table in a stored procedure and view it in management studio?

I've tried a create table command and a select into command. Both execute without errors. However the Object Explorer does not seem to register that a table exists in the selected database. What's the deal? When I create a table in a stored procedure where does it go? Is it a temporary table? How do I verify the table has been correctly populated?

Any help is appreciated,

Ryan

CREATE TABLE CEA.DBO.RYAN_TEMP
      (POLICY_ID INT)
      
      CREATE TABLE CEA.DBO.CEA_TRANS
      (POLICY_ID INT)
INSERT INTO RYAN_TEMP
                      (POLICY_ID)
VALUES     (96)
            SELECT policy_id
      INTO CEA.DBO.RYAN_TEMP
      FROM POLICY
      WHERE policy_id = 96
0
Comment
Question by:888_ryan_888
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18801538
>>However the Object Explorer does not seem to register that a table exists in the selected database. What's the deal? <<
Have you tried refreshing?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18801554


CREATE TABLE cea.DBO.RYAN_TEMP
      (POLICY_ID INT)
CREATE TABLE cea.DBO.CEA_TRANS
      (POLICY_ID INT)

-- try to use fully qualified names in the insert/select part too

INSERT INTO cea.DBO.RYAN_TEMP (POLICY_ID)
VALUES     (96)

SELECT * FROM cea.DBO.RYAN_TEMP
0
 

Author Comment

by:888_ryan_888
ID: 18801555
Yes, I've tried refreshing.

Can you view a table created through a stored procedure?

0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:888_ryan_888
ID: 18801560
I should be able to view the table regardless of values that are present in the table.

Can you view a table created in a stored procedure?
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18801576
you can check something like this immediately after createing

create table test( i int)
If OBJECT_ID('test') IS NOT NULL
  Print  'table created'
Else
  Print 'No table available'
0
 

Author Comment

by:888_ryan_888
ID: 18801667
hmmm i can't get the object_id code to work, also  I've searched the drives for anything named ryan_temp and nothing comes up.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18801742
try this

SELECT OBJECT_ID('cea.DBO.RYAN_TEMP')
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18801756
>>I've searched the drives for anything named ryan_temp and nothing comes up. <<
That could be viewed by some as a wild goose chase.
0
 

Author Comment

by:888_ryan_888
ID: 18801804
yeah, the select doesn't fail, so it exists somewhere as something, but evidently not a table viewable in the object explorer. The idea here is to populate a table for export to text as a flat file. I'll need to view the table and may export it through ms access in which case the table will actually need to real in the same way that all of the other dbos in the database exist.

0
 

Author Comment

by:888_ryan_888
ID: 18801805
hahaha ... as could this, simply the only option available to me right now,
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21890440
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

839 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