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 |
Sini
Starting Member
18 Posts |
Posted - 2007-08-14 : 09:06:07
|
Hello I need to truncate a table everytime the SQL service restarts - can anyone help?Thanks. |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-14 : 10:05:55
|
exec sp_procoption N'YourStoredProcedure', 'startup', 'on'and you truncate the tables in your YourStoredProcedure_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
Sini
Starting Member
18 Posts |
Posted - 2007-08-14 : 10:07:02
|
Thanks for the swift reply - im gonna give it a try. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-14 : 10:10:05
|
note that this sproc must be owned by dbo and reside in master database_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
Sini
Starting Member
18 Posts |
Posted - 2007-08-14 : 10:56:40
|
I created it in the master database - but how do i get it to truncate a table that resides in another database?I cant get a USE <databasename> to work in a create stored proc. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-14 : 11:15:56
|
truncate table dbName.OwnerName.tableName_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
Sini
Starting Member
18 Posts |
Posted - 2007-08-14 : 11:20:06
|
Thanks. |
 |
|
|
|
|