-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathPMDB.Remove orphan project ids.sql
35 lines (28 loc) · 1.23 KB
/
PMDB.Remove orphan project ids.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*---------------------------------------------------------------------------+
| Purpose: Remove orphan projects
| Note: SQLCmdMode Script
+----------------------------------------------------------------------------*/
:setvar _server "Server1"
:setvar _user "***username***"
:setvar _password "***password***"
:setvar _database "PMDB_TEST"
:connect $(_server) -U $(_user) -P $(_password)
USE [$(_database)];
GO
PRINT '====================================================================='
PRINT 'Find orphan project ids. '
PRINT '====================================================================='
GO
SELECT proj_id FROM project WHERE proj_id NOT IN(SELECT proj_id FROM projwbs)
PRINT '====================================================================='
PRINT 'remove orphan project ids. '
PRINT '====================================================================='
GO
--declare @ret integer, @msg varchar(255)
--BEGIN
--EXEC cascade_delete 'PROJECT','*****', @ret output, @msg output --replace with the proj_id from above
--END
PRINT '====================================================================='
PRINT 'Finished!'
PRINT '====================================================================='
GO