473,516 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stuck with Truncate

48 New Member
Hi,

I have a SQL Server 2005, used in combination with Access VBA.
The SQL Server uses Windows Authenticatiob

I want to do "Truncate Table" from within VBA.

At first I wrote the Truncate in VBA (ExecuteSPT), which works fine to me (owner of the SQLserver Database/Table). However running the code on another PC it fails. It's because of the rights, making that user Owner solves the problem, but this ain't an option.

Can this be solved or is it mandatory to go for PlanB ?

PlanB: Because I read somewhere, Stored procedures can be assigned to users, I wrote the Truncate stuff as a stored procedure, which I can execute (Parse) succesfully, but can't find a way to save it as a Stored procedure on the server. Despite I started with "New Stored procedure", the save option always results in a local save on my Desktop, not on the server

[HTML]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [TruncateTable]
@TableName VARCHAR(50)
AS
BEGIN
TRUNCATE TABLE [dbo].[@TableName]
END
GO
[/HTML]

Even If the save would be ok I'll still have to find out how to allow the Stored Procedure for an user, and how to launch it from VBA.

I've been Googling / Reading, but can't find one "complete" example as a good (noob-understandable) example

Someone any ideas ?
May 27 '08 #1
1 1856
ck9663
2,878 Recognized Expert Specialist
You don't save stored procedure as file like other development/data base tool that you can call.

Open a query analyzer and execute your script. The problem with this is you have to create one stored proc for every user, too messy.

You might need to give execute rights for those users and call the stored proc using the full naming convention db.dbo.sp

-- CK
May 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4519
by: martin | last post by:
Hi, We have a heavily used production server and a table which logs every hit on a web site. This table has grown large over time and we want to clear it down as efficiently as possible. We would like to issue a truncate table statement, but with millions of rows we are a bit wary of how this will affect server performance. The alternative is...
3
8643
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and get all table names in my database. .... exec ('truncate table ' + @TableName)
1
3025
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would like your inputs and comments. 1) TX log truncate: In the existing environment, there are scheduled jobs to truncate transaction log of each...
2
47546
by: rdraider | last post by:
Hi, I am trying to create a script that deletes transaction tables and leaves master data like customer, vendors, inventory items, etc. How can I use TRUNCATE TABLE with an Exists? My problem is I have 200+ tables, if I simply use a list like: truncate table01 truncate table02 truncate table03 ....
9
14676
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using "load" and is fast? Thanks, Sumanth
14
12257
by: Sala | last post by:
Hi I want to truncate all data in database ... pls help me how i ll truncate?
10
13868
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/c0023297.htm where it says: After an ALTER TABLE statement containing REORG-recommended operations, you can execute only the following statements on a...
5
1091
by: Timothy Madden | last post by:
Hello I see there is now why to truncate a file (in C or C++) and that I have to use platform-specific functions for truncating files. Anyone knows why ? I mean C/C++ evolved over many years now, and still, people making _the_ standards never decided to include such a function. Even in POSIX it was included only in recent versions,...
8
7675
by: ananthaisin | last post by:
How to reduce the table size for any table while using truncate or delete statements. In oracle 8i it was truncating the storage space but in 10g it is not .... I have given truncate statement in a procedure to drop the storage of a table used... when its record count exceeds 500. BEGIN i:= 0; FOR CC IN NLD LOOP
0
7182
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...
0
7408
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. ...
1
7142
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...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
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...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1624
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
0
488
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...

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.