Stored Procedure Problem --- Driving me nuts! 
Author Message
 Stored Procedure Problem --- Driving me nuts!

Are you running this while other users are connected?  The table may have a
lock on it.  What errors do you get.
--
Jon Raymond


Quote:
> Hi,

> I have a stored procedure problem I want to solve.  I could do what I want
> by writing a function outside of SQL Server, but I would really like to
get
> the stored proc working if possible.   All I want is a stored proc that
> takes a table name as an input parameter, and deletes all records in the
> table.  The definition that I have written below produces the error

> CREATE PROCEDURE delete_table_data

> AS
> -- Delete all records from the table

> DELETE

> Can anyone tell me why this is?  I assumed that the input parameter could
be
> substituted for any object name.  Is this not correct?

> TIA

> Aaron



Sun, 19 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!

Heya, Aaron!

In order to dynamically specify a table, you'll need to resort to the
EXECUTE command (or sp_executesql).  You could replace the "guts" of your
stored procedure with:


Of course, to do some more sophisticated things with dynamic SQL, you'll
need to understand the scope of the statements that are issued with the
EXECUTE command.  But, for this example, it should suffice!  :-)

Hope this helps!

John Peterson


Quote:
> Hi,

> I have a stored procedure problem I want to solve.  I could do what I want
> by writing a function outside of SQL Server, but I would really like to
get
> the stored proc working if possible.   All I want is a stored proc that
> takes a table name as an input parameter, and deletes all records in the
> table.  The definition that I have written below produces the error

> CREATE PROCEDURE delete_table_data

> AS
> -- Delete all records from the table

> DELETE

> Can anyone tell me why this is?  I assumed that the input parameter could
be
> substituted for any object name.  Is this not correct?

> TIA

> Aaron



Sun, 19 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!
Hi,

I have a stored procedure problem I want to solve.  I could do what I want
by writing a function outside of SQL Server, but I would really like to get
the stored proc working if possible.   All I want is a stored proc that
takes a table name as an input parameter, and deletes all records in the
table.  The definition that I have written below produces the error


AS
-- Delete all records from the table

DELETE

Can anyone tell me why this is?  I assumed that the input parameter could be
substituted for any object name.  Is this not correct?

TIA

Aaron



Mon, 20 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!
Hi there

Try the following


AS

.........and then to execute........

EXECUTEtesting_1 'site'

Hope this helps
Karina Scholtz
Accord Business Solutions
South Africa



Quote:
> Hi,

> I have a stored procedure problem I want to solve.  I could do what I
want
> by writing a function outside of SQL Server, but I would really like
to get
> the stored proc working if possible.   All I want is a stored proc
that
> takes a table name as an input parameter, and deletes all records in
the
> table.  The definition that I have written below produces the error

> CREATE PROCEDURE delete_table_data

> AS
> -- Delete all records from the table

> DELETE

> Can anyone tell me why this is?  I assumed that the input parameter
could be
> substituted for any object name.  Is this not correct?

> TIA

> Aaron

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 20 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!
Hi there

Try the following


AS

.........and then to execute........

EXECUTEtesting_1 'site'

Hope this helps
Karina Scholtz
Accord Business Solutions
South Africa



Quote:
> Hi,

> I have a stored procedure problem I want to solve.  I could do what I
want
> by writing a function outside of SQL Server, but I would really like
to get
> the stored proc working if possible.   All I want is a stored proc
that
> takes a table name as an input parameter, and deletes all records in
the
> table.  The definition that I have written below produces the error

> CREATE PROCEDURE delete_table_data

> AS
> -- Delete all records from the table

> DELETE

> Can anyone tell me why this is?  I assumed that the input parameter
could be
> substituted for any object name.  Is this not correct?

> TIA

> Aaron

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 20 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!
O.K.

I've now managed to solve this problem (no thanks to the help).  By looking
through the system SP's, I noticed a trend of building the TSQL statement in

effective.

PS:  If you know of a better way, please let me know.

Cheers Aaron.

Quote:

>Hi,

>I have a stored procedure problem I want to solve.  I could do what I want
>by writing a function outside of SQL Server, but I would really like to get
>the stored proc working if possible.   All I want is a stored proc that
>takes a table name as an input parameter, and deletes all records in the
>table.  The definition that I have written below produces the error

>CREATE PROCEDURE delete_table_data

>AS
>-- Delete all records from the table

>DELETE

>Can anyone tell me why this is?  I assumed that the input parameter could
be
>substituted for any object name.  Is this not correct?

>TIA

>Aaron



Mon, 20 May 2002 03:00:00 GMT
 Stored Procedure Problem --- Driving me nuts!
If you have SQL 6.5 + try




Mon, 20 May 2002 03:00:00 GMT
 
 [ 7 post ] 

 Relevant Pages 

1. Synax problem driving me nuts

2. MS Access Problem - Driving me Nuts

3. Driving me nuts

4. I'm sure it something simple but it's driving me nuts :-(

5. HTTP 404 - File not found Driving me NUTS!!!!

6. Driving me nuts!!

7. adErrInvalidArgument driving me nuts! please advise

8. JDBC Errors are driving me nuts!!!

9. DAO Issue -- Invalid Page Fault Driving Me Nuts!

10. This is driving me NUTS!!!!

11. : BDE drives me nuts!(ODBC)

12. help vb & access2k is driving me nuts


 
Powered by phpBB® Forum Software