Hello Siingh,
Deleting a project through SQL is definitely doable, but there is some work involved due to triggers and constraints. In an effort to help the community between now and when we get a release out which includes the functionality via the UI, we have created a script to allow you to manually perform this action.
To use the script, you will need to know the Project ID of the project you wish to delete. This can be retrieved via the URL in your browser when the project is open. For example, when open to the Dashboard I get a URL like this:
http://localhost:9898/#/Project/3/Dashboard
In this case, the Project ID is
3.
To run the script, open SQL Server Management Studio and create a new query. Paste the contents of the script from below, then take the Project ID value and replace the placeholder text PASTE_PROJECT_ID_HERE with that integer value.
WARNING: *** This script is run at your own risk! Telerik is not responsible for any loss of data that may occur! ***
You are encouraged to perform a full database backup prior to running the script, as modifications cannot be undone!
USE TeamPulse
BEGIN
TRAN DeleteProject
DECLARE
@ProjectIDToDelete
INT
SET
@ProjectIDToDelete = PASTE_PROJECT_ID_HERE
Print
'Disabling all triggers...'
SET
NOCOUNT
ON
IF EXISTS (
SELECT
*
FROM
sys.objects
WHERE
object_id = OBJECT_ID(N
'#AllTriggers'
)
AND
type
in
(N
'U'
))
DROP
TABLE
#AllTriggers
SELECT
T.
Name
as
TrigName, o.
Name
as
TabName, s.
Name
as
SchemaName
INTO
#AllTriggers
FROM
sys.triggers T
join
sys.objects o
ON
T.parent_Id = o.object_ID
JOIN
sys.schemas s
ON
o.schema_Id = s.Schema_ID
DECLARE
TrigCurs
Cursor
FOR
SELECT
TrigName, TabName, SchemaName
FROM
#AllTriggers
OPEN
TrigCurs
DECLARE
@TrigName
varchar
(250), @TabName
varchar
(250), @SchameName
VarChar
(250), @cmd
varchar
(1000)
FETCH
Next
FROM
TrigCurs
INTO
@TrigName , @TabName , @SchameName
WHILE @@Fetch_Status = 0
BEGIN
SET
@cmd =
'disable trigger all on ['
+ @SchameName+
'].['
+@TabName+
'];'
EXEC
(@cmd)
FETCH
Next
FROM
TrigCurs
INTO
@TrigName , @TabName , @SchameName
END
Print
'Deleting Project data...'
delete
from
AttachmentFile
where
ProjectID = @ProjectIDToDelete
delete
from
Attachment
where
ProjectID = @ProjectIDToDelete
delete
from
TestCase
where
ProjectID = @ProjectIDToDelete
delete
from
Task
where
ProjectID = @ProjectIDToDelete
delete
from
Hyperlink
where
ProjectID = @ProjectIDToDelete
delete
from
StoryPersona
where
ProjectID = @ProjectIDToDelete
delete
from
StoryRelationship
where
ProjectID = @ProjectIDToDelete
delete
from
StoryRichDescription
where
ProjectID = @ProjectIDToDelete
delete
from
Story
where
ProjectID = @ProjectIDToDelete
delete
from
SynchronizationError
where
ProjectID = @ProjectIDToDelete
delete
from
Area
where
ProjectID = @ProjectIDToDelete
delete
from
Iteration
where
ProjectID = @ProjectIDToDelete
delete
from
Timeline
where
ProjectID = @ProjectIDToDelete
delete
from
Persona
where
ProjectID = @ProjectIDToDelete
delete
from
ProjectUser
where
ProjectID = @ProjectIDToDelete
delete
from
ProjectSync
where
ProjectID = @ProjectIDToDelete
delete
from
ProjectTag
where
ProjectID = @ProjectIDToDelete
delete
from
project
where
projectid = @ProjectIDToDelete
Print
'Enabling all triggers...'
DECLARE
TrigCurs2
Cursor
FOR
SELECT
TrigName, TabName, SchemaName
from
#AllTriggers
OPEN
TrigCurs2
DECLARE
@TrigName2
varchar
(250), @TabName2
varchar
(250), @SchameName2
VarChar
(250), @cmd2
varchar
(1000)
FETCH
Next
from
TrigCurs2
into
@TrigName2 , @TabName2 , @SchameName2
WHILE @@Fetch_Status = 0
BEGIN
SET
@cmd2 =
'enable trigger all on ['
+ @SchameName2+
'].['
+@TabName2+
'];'
EXEC
(@cmd2)
FETCH
Next
FROM
TrigCurs2
INTO
@TrigName2 , @TabName2 , @SchameName2
END
DROP
TABLE
#AllTriggers
COMMIT
TRAN DeleteProject
Print
'Script Complete.'
Regards,
David Harris
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the
Telerik Public Issue Tracking system and vote to affect the priority of the items