Solved

Create Table Problem

Posted on 1998-08-19
6
188 Views
Last Modified: 2010-03-19
Greetings,
I am trying to create a table using using a sp_ and the following code:

CREATE TABLE Summary_Tbl
(Criimi             varchar(6),
PropertyNBR             int,
Report_Period            datetime,
ChartofAccount_Code      varchar(5),
Revenue                  money,
Expenses            money,
Excluded            money)

The sp seems to work fine (i.e., no errors) but the table is never created. I get an Invalid Object Name error later when I try to merging a number of temp tables into Summary_Tbl.

What's up? Besides the sky....

Thanks,
Brad
0
Comment
Question by:bhummel
6 Comments
 
LVL 4

Expert Comment

by:vvk
ID: 1089631
Does your script working fine when you start it from isqlw window?
0
 
LVL 2

Accepted Solution

by:
mvz121697 earned 100 total points
ID: 1089632
You can only create temporary tables from within a stored proc.
They are created in database tempdb and are only there as long as your sp runs.
0
 

Author Comment

by:bhummel
ID: 1089633
I found that out last night. So, I created the table using enterprise manager. What I want to do is keep the same table but remove the records (I though "DROP TABLE" would do this) but now when I reference the table I get:
Invalid object name 'Statement_Summary_Tbl'
when I try to INSERT INTO 'Statement_Summary_Tbl'

Is there a better way to remove all the records each time the sp is executed?

FYI- vvk I am now doing all of this in Isql.

Thanks,
Brad
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Expert Comment

by:mvz121697
ID: 1089634
With DROP TABLE you remove the whole table structure !
To remove only the records, just do:

DELETE FROM Table_Name


0
 
LVL 2

Expert Comment

by:mvz121697
ID: 1089635
bhummel,

A correction to my first answer,
It _is_ possible to create a table from within a stored proc.
(At least with SQL-Server 6.5)

I think your DROP TABLE command was your problem in the first place.
This command does totally remove the table.

0
 
LVL 2

Expert Comment

by:formula
ID: 1089636
Within a stored procedure, I use TRUNCATE TABLE to keep the table structure and get rid of the records.  It's faster than
DELETE because it does not log individual row deletions.  If you
table doesn't contain rows you want to keep permanently, its the way to go.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help Required 2 29
Sql server function help 15 27
Help Required 3 89
How to construct an if else statement from existing code 6 19
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now