473,806 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tables and Stored Procedures

SQL Server 2000:

Question 1

If you drop / rename a table and then recreate the table with the SAME
NAME, what impact does it have on stored procedures that use these tables?
From a system perspective, do you have to rebuild / recompile ALL the stored
procedures that use this table?

I had a discussion with someone that said that this is a good idea, since
the IDs of the tables change in sysobjects and from a SQL SERVER query plan
perspective, this needs to be done...

Question 2

If you Truncate a Tables as part of a BEGIN TRANSACTION, what happens if an
error occurs? Will it Rollback? The theory is that it won't because
Truncate doesn't utilize the logs where as Delete From uses the SQL Logs?

Thanks!





Jul 20 '05 #1
3 2113
If you drop and recreate a table in SQL 2000, existing query plans are
invalidated. Procedures that reference the table are automatically
recompiled the next time they are executed so you don't need to take any
special action.

TRUNCATE TABLE is minimally logged so the operation can be rolled back just
like other SQL statements. To illustrate:

CREATE TABLE MyTable(Col1 int)
INSERT INTO MyTable VALUES(1)
BEGIN TRAN
TRUNCATE TABLE MyTable
SELECT * FROM MyTable
ROLLBACK
SELECT * FROM MyTable

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Barry Young" <yo******@insig htbb.com> wrote in message
news:sP_ad.2355 88$D%.109359@at tbi_s51...
SQL Server 2000:

Question 1

If you drop / rename a table and then recreate the table with the SAME
NAME, what impact does it have on stored procedures that use these tables?
From a system perspective, do you have to rebuild / recompile ALL the
stored procedures that use this table?

I had a discussion with someone that said that this is a good idea, since
the IDs of the tables change in sysobjects and from a SQL SERVER query
plan perspective, this needs to be done...

Question 2

If you Truncate a Tables as part of a BEGIN TRANSACTION, what happens if
an error occurs? Will it Rollback? The theory is that it won't because
Truncate doesn't utilize the logs where as Delete From uses the SQL Logs?

Thanks!




Jul 20 '05 #2
Thanks Dan!

That is great info!

I assume that all related stored procs to that table are just recompiled
once, correct?

Barry

"Dan Guzman" <gu******@nospa m-online.sbcgloba l.net> wrote in message
news:r7******** *********@newss vr11.news.prodi gy.com...
If you drop and recreate a table in SQL 2000, existing query plans are
invalidated. Procedures that reference the table are automatically
recompiled the next time they are executed so you don't need to take any
special action.

TRUNCATE TABLE is minimally logged so the operation can be rolled back
just like other SQL statements. To illustrate:

CREATE TABLE MyTable(Col1 int)
INSERT INTO MyTable VALUES(1)
BEGIN TRAN
TRUNCATE TABLE MyTable
SELECT * FROM MyTable
ROLLBACK
SELECT * FROM MyTable

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Barry Young" <yo******@insig htbb.com> wrote in message
news:sP_ad.2355 88$D%.109359@at tbi_s51...
SQL Server 2000:

Question 1

If you drop / rename a table and then recreate the table with the SAME
NAME, what impact does it have on stored procedures that use these
tables? From a system perspective, do you have to rebuild / recompile ALL
the stored procedures that use this table?

I had a discussion with someone that said that this is a good idea, since
the IDs of the tables change in sysobjects and from a SQL SERVER query
plan perspective, this needs to be done...

Question 2

If you Truncate a Tables as part of a BEGIN TRANSACTION, what happens if
an error occurs? Will it Rollback? The theory is that it won't because
Truncate doesn't utilize the logs where as Delete From uses the SQL
Logs?

Thanks!





Jul 20 '05 #3
Each proc will recompile the next time it is executed. Normal caching and
recompilation rules apply for subsequent executions.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Barry Young" <yo******@insig htbb.com> wrote in message
news:Lh%ad.2283 42$MQ5.135764@a ttbi_s52...
Thanks Dan!

That is great info!

I assume that all related stored procs to that table are just recompiled
once, correct?

Barry

"Dan Guzman" <gu******@nospa m-online.sbcgloba l.net> wrote in message
news:r7******** *********@newss vr11.news.prodi gy.com...
If you drop and recreate a table in SQL 2000, existing query plans are
invalidated. Procedures that reference the table are automatically
recompiled the next time they are executed so you don't need to take any
special action.

TRUNCATE TABLE is minimally logged so the operation can be rolled back
just like other SQL statements. To illustrate:

CREATE TABLE MyTable(Col1 int)
INSERT INTO MyTable VALUES(1)
BEGIN TRAN
TRUNCATE TABLE MyTable
SELECT * FROM MyTable
ROLLBACK
SELECT * FROM MyTable

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Barry Young" <yo******@insig htbb.com> wrote in message
news:sP_ad.2355 88$D%.109359@at tbi_s51...
SQL Server 2000:

Question 1

If you drop / rename a table and then recreate the table with the SAME
NAME, what impact does it have on stored procedures that use these
tables? From a system perspective, do you have to rebuild / recompile
ALL the stored procedures that use this table?

I had a discussion with someone that said that this is a good idea,
since the IDs of the tables change in sysobjects and from a SQL SERVER
query plan perspective, this needs to be done...

Question 2

If you Truncate a Tables as part of a BEGIN TRANSACTION, what happens if
an error occurs? Will it Rollback? The theory is that it won't because
Truncate doesn't utilize the logs where as Delete From uses the SQL
Logs?

Thanks!






Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2537
by: Ezekiël | last post by:
Hello, I need some help with implenting the following: I recently migrated from access to sql server and i now i want to use maintainable permissions on my tables, views, etc. The access database will serve as a front-end. I've created for testing purposes an testaccount with only a public role to access to my database.
4
2463
by: serge | last post by:
I tried all the INFORMATION_SCHEMA on SQL 2000 and I see that the system tables hold pretty much everything I am interested in: Objects names (columns, functions, stored procedures, ...) stored procedure statements in syscomments table. My questions are: If you script your whole database everything you end up having in the text sql scripts, are those also located in the system tables? That means i could simply read those system tables...
2
6980
by: Keith Watson | last post by:
Hi, we are currently implementing an application running on DB2 V7 on Z/OS using largely COBOL stored procedures, managed using WLM. Some of these stored procedures declared global temporary tables, which are declared with ON COMMIT DELETE ROWS to perform work on and then return these temporary tables to the client (which is a message driven EJB connecting via DB2 connect). The client reads the data in the result sets, creates some XML...
5
1836
by: serge | last post by:
What is the best way to run one command and have a database be created and sql scripts run on it to create the tables, indexes, triggers, procedures, etc.? Is there an existing tool free or commercial to automate this? Thank you
15
7266
by: brettclare | last post by:
I have linked a large SQL Server table to Access, however 'only' 2,195,439 records are shown and are available to query. Can I increase the size (cache??)/number of records showing in Access? Thank you.
3
2705
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
6
4723
by: heyvinay | last post by:
I have transaction table where the rows entered into the transaction can come a result of changes that take place if four different tables. So the situation is as follows: Transaction Table -TranId -Calc Amount Table 1 (the amount is inserted into the transaction table) - Tb1Id
2
4079
by: Joe Kovac | last post by:
Hi! The informations of our customers are saved in two tables: Customer: ID, CustomerNumber, ... + Person_ID Person: ID, Name, ... I want to have an editable GridView displaying all the data and being able to add, edit and delete customers.
3
5132
by: Bret Kuhns | last post by:
I recently started a co-op/internship at a company and they are looking to migrate a large legacy supported application from OLEDB to SQL Server. I'm doing prelim work in experimenting with the options available. The application is huge (1+ million lines of C++ code), so it'd be quite a bit of man hours to adapt all the database code for SQL Server. I stumbled upon linked tables in an OLEDB file to an ODBC source (such as SQL Server) and...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.