Re: table variable vs temp table?

Re: table variable vs temp table?

 

  

I'm interested in truncating tables.

How do I truncate a table? What's exactly does that?

Jaír

Carter Phillip wrote:

>Well "a couple thousand rows" rules out a table variable.
>
>What I'd do is have a temp table with an extra ID column. Then use a
>WHILE loop instead of a cursor.
>
>SELECT @var = MIN(ID) FROM #tbl
>
>WHILE @var is not null
>BEGIN
>
>Do Processing
>
>SELECT @var = MIN(ID) FROM #tbl WHERE ID > @var
>
>END
>
>
>If you don't have to worry about multiple users running the process,
>create a permanent table in the DB. Just TRUNCATE it before inserting.
>
>
>Thanks
>Phillip Carter
>Ph: +61 3 9235 1691
>
>
>-----Original Message-----
>From: Hugh du Toit
>[mailto:mssqldba-ezmlmshield-x97524742.[Email address protected]
>
>Sent: Friday, 27 May 2005 7:33 PM
>To: LazyDBA Discussion
>Subject: table variable vs temp table?
>
>
>Hi,
>
>I run a stored procedure and it returns a result of a couple thousand
>rows. I need to get these rows into a temp table or table variable, and
>then loop through the results. I need to run 1 or 2 queries for each
>rows in this result set. What way is the best to go?
>
>
>Table variable / temp table. Cursor / while loop. I want to pass the
>results to a different stored procedure to be processed like explained
>above.
>
>What is the best practice?
>
>Thanks!
>Hugh
>
>
>
>---------------------------------------------------------------------
>TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
>http://www.LazyDBA.com To unsubscribe:
>http://www.lazydba.com/unsubscribe.html
>
>
>IMPORTANT DISCLAIMER - THIS MAY AFFECT YOUR LEGAL RIGHTS:
>
>Because this document has been prepared without consideration of any
>specific clients investment objectives, financial situation or needs,
>a Bell Potter Securities Limited investment adviser should be
>consulted before any investment decision is made.
>
>While this document is based on the information from sources which
>are considered reliable, Bell Potter Securities Limited, its directors,
>employees and consultants do not represent, warrant or guarantee,
>expressly or impliedly, that the information contained in this document
>is complete or accurate.
>
>Nor does Bell Potter Securities Limited accept any responsibility to
>inform you of any matter that subsequently comes to its notice, which
>may affect any of the information contained in this document.
>
>This document is a private communication to clients and is not intended
>for public circulation or for the use of any third party, without the
>prior approval of Bell Potter Securities.
>
>
>Disclosure of Interest: Bell Potter Securities Limited receives commission
>from dealing in securities and its authorised representatives, or introducers
>of business, may directly share in this commission. Bell Potter Securities
>and its associates may hold shares in the companies recommended.
>
>Bell Potter Securities Limited ABN 25 006 390 772 AFS Licence No. 243480
>
>
>---------------------------------------------------------------------
>TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
>Website : http://www.LazyDBA.com
>To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
>
>
>


--
Jaír E. Hnatiuk
Responsable de Sistemas
Runfo S.A.
TE: (02202) 44-1475
Fax: (02202) 44-1476


MS Sql Server LazyDBA home page