473,383 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 2087
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******@insightbb.com> wrote in message
news:sP_ad.235588$D%.109359@attbi_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******@nospam-online.sbcglobal.net> wrote in message
news:r7*****************@newssvr11.news.prodigy.co m...
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******@insightbb.com> wrote in message
news:sP_ad.235588$D%.109359@attbi_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******@insightbb.com> wrote in message
news:Lh%ad.228342$MQ5.135764@attbi_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******@nospam-online.sbcglobal.net> wrote in message
news:r7*****************@newssvr11.news.prodigy.co m...
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******@insightbb.com> wrote in message
news:sP_ad.235588$D%.109359@attbi_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
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...
4
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...
2
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...
5
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...
15
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? ...
3
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...
6
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...
2
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...
3
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.