pjnovak007
Starting Member
19 Posts |
Posted - 2010-07-02 : 11:25:57
|
I have this code and my boss wants me to skip a database called "Fish4" how would i do that?The job isnt working because it's trying to find the database and the database was deleted (old) I want to keep the historical data so i dont want to delete - just not update this database anymore.-----------------------------------USE [CrossDBReports]GO/****** Object: StoredProcedure [dbo].[adm_PopulateUIInfo] Script Date: 07/02/2010 10:48:30 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[adm_PopulateUIInfo]@startDate DateTime,@endDate DateTimeASBEGINSET NOCOUNT ONDeclare @publisherId UniqueIdentifierDeclare @databaseName VarChar(50)Declare @databaseLocation VarChar(50)Declare @sql VarChar(1024)Create Table #tmpUI(usrId UniqueIdentifier PRIMARY KEY Clustered,emailAddress VarChar(100),ClientName VarChar(100),clientAssignedId VarChar(75),numJobs int,numApplicants int,percentViewedApplicants int,isUsedFolders Bit Default 0,isModifyScore Bit Default 0,isModifyQuestions Bit Default 0,isPrintButton Bit Default 0,isForwardApp Bit Default 0,isUsedNotes Bit Default 0,isCreateFolders Bit Default 0,isRenewAd Bit Default 0,loginCount Int Default 0,loginDate DateTime,clientId UniqueIdentifier,publisherId UniqueIdentifier)DECLARE curPublishers CursorLOCALFORWARD_ONLYREAD_ONLYFor Select publisherId,databaseName,databaseLocationFrom PublishersOpen curPublishersFETCH NEXTFROM curPublishersINTO @publisherId,@databaseName,@databaseLocationWHILE @@fetch_status = 0 BeginSelect @sql = nullSelect @sql = 'Insert Into #tmpUI (usrId,emailAddress,ClientName,clientAssignedId,numJobs,numApplicants,percentViewedApplicants,isUsedFolders,isModifyScore,isModifyQuestions,isPrintButton,isForwardApp,isUsedNotes,isCreateFolders,isRenewAd,loginCount,loginDate,clientId)' +' exec [' + @databaseLocation + '].' +@databaseName + '.dbo.qry_UIReport ''' +Cast(@publisherId As VarChar(39)) + ''', ' +'''' + Cast(@startDate As VarChar(30)) + ''', ' +'''' + Cast(@endDate As VarChar(30)) + ''', ' + 'Null'exec (@sql)Update #tmpUI Set publisherId=@publisherId Where publisherId Is NullFETCH NEXTFROM curPublishersINTO @publisherId,@databaseName,@databaseLocationEndClose curPublishersDeallocate curPublishersUpdate UIInfoSet usrId=UI.usrId,emailAddress=UI.emailAddress,ClientName=UI.clientName,clientAssignedId=UI.clientAssignedId,numJobs=UI.numJobs,numApplicants=UI.numApplicants,percentViewedApplicants=UI.percentViewedApplicants,isUsedFolders=UI.isUsedFolders,isModifyScore=UI.isModifyScore,isModifyQuestions=UI.isModifyQuestions,isPrintButton=UI.isPrintButton,isForwardApp=UI.isForwardApp,isUsedNotes=UI.isUsedNotes,isCreateFolders=UI.isCreateFolders,isRenewAd=UI.isRenewAd,loginCount=UI.loginCount,loginDate=UI.loginDate,clientId=UI.clientId,publisherId=UI.publisherIdFrom #tmpUI UIInner Join dbo.UIInfo U On U.usrId=UI.usrIdInsert Into UIInfo (usrId,emailAddress,ClientName,clientAssignedId,numJobs,numApplicants,percentViewedApplicants,isUsedFolders,isModifyScore,isModifyQuestions,isPrintButton,isForwardApp,isUsedNotes,isCreateFolders,isRenewAd,loginCount,loginDate,clientId,publisherId)Select usrId,emailAddress,ClientName,clientAssignedId,numJobs,numApplicants,percentViewedApplicants,isUsedFolders,isModifyScore,isModifyQuestions,isPrintButton,isForwardApp,isUsedNotes,isCreateFolders,isRenewAd,loginCount,loginDate,clientId,publisherIdFrom #tmpUI UIWhere Not Exists (Select usrIdFrom dbo.UIInfoWhere UI.usrId=dbo.UIInfo.usrId)Drop Table #tmpUISet NoCount Off;ENDPatrick |
|