Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pubs
Starting Member
3 Posts |
Posted - 2005-06-17 : 09:05:08
|
| Hi,Im creating a user defined function which takes as a parameter the table name.My problem is i cant do this: Delete from @Table_nameany clue how to do this?thanks in advance |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-17 : 09:10:55
|
in a function you can't.write it as a stored procedure.Go with the flow & have fun! Else fight the flow |
 |
|
|
pubs
Starting Member
3 Posts |
Posted - 2005-06-17 : 09:52:06
|
| Doesnt work! :\ what now?CREATE PROCEDURE DeleteTable @TableName varchar(20)AS begindelete from @tablenameendGO |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-17 : 09:54:21
|
exec('delete from ' + @tablename)Go with the flow & have fun! Else fight the flow |
 |
|
|
Thrasymachus
Constraint Violating Yak Guru
483 Posts |
Posted - 2005-06-17 : 09:54:49
|
| you need to use sp_executesql.Sean RoussyPlease backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own. |
 |
|
|
pubs
Starting Member
3 Posts |
Posted - 2005-06-17 : 11:22:57
|
| Thanks a lot spirit1 and Thrasymachus ;) |
 |
|
|
|
|
|