Why Does Error Log Show Database Restarting Everytime A Transactionlog Backup Runs?
Feb 11, 2008
Why does Error log show database restarting everytime a transaction
log backup runs?
It also runs a checkdb as well.
The log backups are scheduled through a maintenance plan.
Is this normal?
View 1 Replies
ADVERTISEMENT
Oct 13, 2015
We are running SQL Server 2014 Web Edition (64-bit). On three occasions now we have had two of our live secondary log shipping databases become unusable through the log shipping process. We ship logs to these databases every five minutes, and generally the process works fine. However, on three occasions in as many months we have suddenly received alerts warning us that the transaction log restores could not be performed on the secondary databases. The SQL Server Error Log revealed the following:
Date,Source,Severity,Message
10/13/2015 04:01:16,spid52,Unknown,Setting database option SINGLE_USER to ON for database 'ObfuscatedName'.
10/13/2015 04:01:17,spid52,Unknown,Starting up database 'ObfuscatedName'.
10/13/2015 04:01:17,spid52,Unknown,Recovery is writing a checkpoint in database 'ObfuscatedName' (8). This is an informational message only.
[code].....
An error occurred during recovery, preventing the database 'ObfuscatedName' (8:0) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support."
The extract above shows two previously successful restores to the secondary database. Suddenly, at 04:11:16, the database can no longer be started up or restored to. This is despite CHECKDB giving a clean bill of health only five minutes earlier. The result is that the last three lines are then repeated ad infinitum.
The only way we have managed to get around this issue so far is to replace the secondary database with a recent backup of the primary. Once this is in place, any outstanding transaction logs are successfully applied when the log shipping restore job next runs. However, this seems rather drastic.It is rather concerning that our warm-standby databases continue to become corrupted without any apparent explanation from SQL Server.
View 9 Replies
View Related
May 3, 2007
Hi,
I am running SQL Server Enterprise manager. I was able to connected to the database properly. But after restarting the PC I am getting the following error.
"System.NullReferenceException: Object reference not set to an instance of an object"
The following event where logged in event viewer.
under security: 560, 562, 538, 528.
under system: 7035, 7036
could anbody give hint how to solve this issue?
View 2 Replies
View Related
Feb 18, 2015
SQL Server 2008 r2 - 6 GB memory...I attempted a backup on a 500GB database but it was taking way too long. I checked the resources on the box and saw the CPU at 100%. I checked the SQL Server activity log and saw a hung query (user was not even logged on) that had multiple threads so I killed it and now the CPU utilization is back to normal.
Trouble is, now all of the threads in the activity monitor for the backup show 'suspended' and the backup appears to be not doing anything.
View 3 Replies
View Related
Dec 8, 2007
Hello,
I have moved the system databases master and mssqlsystermresource database. And after that I was unable to restart the MSSQL Server service. This is SQL Server 2005
I had moved the master db under the minimal configuration. using the parameters /f and /T3608
What can I do to restart the SQL
Thanks
View 1 Replies
View Related
Dec 8, 2007
Hello,
I have moved the system databases master and mssqlsystermresource database. And after that I was unable to restart the MSSQL Server service. This is SQL Server 2005
I had moved the master db under the minimal configuration. using the parameters /f and /T3608
What can I do to restart the SQL
Thanks
View 1 Replies
View Related
Dec 8, 2007
Hello,
I have moved the system databases master and mssqlsystermresource database. And after that I was unable to restart the MSSQL Server service. This is SQL Server 2005
I had moved the master db under the minimal configuration. using the parameters /f and /T3608
What can I do to restart the SQL
Thanks
View 3 Replies
View Related
Sep 20, 2006
I have an SSIS task that transforms 70 million rows of data nightly.
The data is dumped and imported fresh every day.
Obviously I don't want my production Transaction Log getting cluttered up with 70 million rows of transaction logs daily.
Is there any way to avoid logging to the transaction log with an SSIS task?
View 5 Replies
View Related
Oct 26, 1999
Hi !
How do I shrink my transaction log device for a database.
I can't dump the database and then restore it because SQL-server wants a database equally large as the one in the dump file.
This is probably very easy but I just don't know how to do it.
Thankful for help
View 3 Replies
View Related
Apr 23, 2008
Performance issue.
I have a very complex Stored Procedure called by a Job that is Scheduled to run every night.
It's execution takes sometimes 1 or 2 hours and sometimes 7 hours or more.
So, if it is running for more than 4 hours I stop the Job and I run the procedure from a Query Window and it never takes more than 2 hours.
Can anyone help me identify the problem ? I want to run from the Job and not to worry about it.
Some more information:
- It is SQL 2000 Enterprise with SP4 in a Cluster (It happens the same way in any node).
- The SQL Server and SQL Agent services run using a Domain Account that have full Administrative access.
- When I connect to a Query Window I also use a Windows Account.
- There is no locks or process bloking or being blocked while the job is running.
- Using the Task Manager the processor activity is ok, no more than 30 % in any processor.
View 15 Replies
View Related
Apr 9, 2008
I have a problem when i restore my .DAT_BAK file. I am getting error like "The backup set holds a backup of a database other than existing database. Restore Database is terminating abnormally".
I tried by using
RESTORE DATABASE <DATABASENAME>
FROM DISK = 'D:DATAMYTEST.DAT_BAK'
WITH MOVE 'VZAI_DATA' TO D:PROGRAM FILES..MSSQLTEST.MDF',
MOVE 'VZAI_LOG' TO D:PROGRAM FILES..MSSQLTEST.LDF',
REPLACE
And also i tried like
RESTORE DATABASE <DATABASENAME>
FROM DISK = 'D:DATAMYTEST.DAT_BAK'
WITH REPLACE
When i use like this,
RESTORE FILELISTONLY FROM DISK = 'D:DATAMYTEST.DAT_BAK'. I am able to get the output as LogicalName, PhysicalName, Type, FileGroupName, Size, etc.
Can i anyone please help me out?
Thanks in Advance,
Anand Rajagopal
View 8 Replies
View Related
Apr 19, 2005
This has been a funny week. things that were running just fine till last week (and for the last many months) have started giving problems despite that I have not changed any settings.
The problem is that one of my scheduled jobs has started failing. The job used to simply takle a backup of a database. When I tried to probe into it and tried to manually take the backup (via Enterprise Manager..) I get a dialog box with the message:
Cannot open backup device 'D:BackupSales'. Device error or device off-line.See the SQL server error log for more details.
Backup database is terminating abnormally.
Can someone kindly guide me how to solve this.
Many TIA.
View 5 Replies
View Related
Apr 25, 2006
I have an ASPNET webform to manage sql express 2005 backups.
If i test the application with the debugger and click the button to made a backup, everything works ok and the backup is created inside my web application folder. When i run the web app under IIS, if I try to do the backup i recieve the following error:
Server Error in '/test' Application.
--------------------------------------------------------------------------------
User does not have permission to perform this action.
User does not have permission to perform this action.
Processed 416 pages for database 'test', file 'test' on file 5.
Processed 3 pages for database 'test', file 'test_log' on file 5.
BACKUP DATABASE successfully processed 419 pages in 0.754 seconds (4.543 MB/sec).
I have included the <localmachine>ASPNET user in my database with
schema 'dbo' and 'db_owner' permission. I have also change the security directives of the folder where the backup is going to be saved (write permission,creation,etc..) but it doesn´t work.
It seems as if the ASPNET user have not enough permissions to do the backup operation
Any Idea??
View 3 Replies
View Related
Oct 5, 2005
I have SQL Server 2000, and our web application is in WebObjects.
I built a trigger on a table that indicates if certain fields in a record have been changed since the last time a report was run from the application.
This trigger runs fine through the Query Analyzer, and runs fine with a direct input through enterprise manager. However, when the WebObjects application tries to update the table, and error is thrown.
Is anyone familiar with a reason why an application would throw an error on an update, when the DB tools do not? If we disable the trigger, the application has no problem updating the table.
Here is the relevant portion of the trigger:
create trigger t_press_run_change
on dbo.press_run_line_item
for insert, update, delete
as
updatepress_run_line_item
setis_changed = 1
from deleted d
join press_run_line_item p on p.press_run_line_item_id = d.press_run_line_item_id
where(p.is_changed = 0 or p.is_changed is null)
AND ((isNull(p.print_quantity,0) <> isNull(d.print_quantity,0))
OR (isNull(p.spoilage_pct,0) <> isNull(d.spoilage_pct,0))
OR(isNull(p.ad_dimension_id,0) <> isNull(d.ad_dimension_id,0))
OR(isNull(p.quarter_fold_id,0) <> isNull(d.quarter_fold_id,0))
OR(isNull(p.max_qty_per_shipment,'') <> isNULL(d.max_qty_per_shipment,''))
OR(isNull(p.packaging_max_height,'') <> isNull(d.packaging_max_height,''))
OR(isNull(p.packaging_max_weight,'') <> isNull(d.packaging_max_weight,''))
OR(isNull(p.packaging_skids,'') <> isNull(d.packaging_skids,''))
OR(isNull(p.packaging_turns,'') <> isNull(d.packaging_turns,''))
OR(isNull(p.packaging_cartons,'') <> isNull(d.packaging_cartons,''))
OR(isNull(p.preprint_delivery_time,'') <> isNull(d.preprint_delivery_time,''))
OR(isNull(p.contact_id,0)<> isNull(d.contact_id,0))
OR(isNull(p.address_company,'')<>isNull(d.address_company,''))
OR(isNull(p.address1,'')<>IsNull(d.address1,''))
OR(isNull(p.address2,'')<>IsNull(d.address2,''))
OR(isNull(p.address_city,'')<>IsNull(d.address_city,''))
OR(isNull(p.address_state,'')<>IsNull(d.address_state,''))
OR(IsNull(p.address_zip,'')<>IsNull(d.address_zip,''))
OR(isNull(p.address_Country_id,'')<>IsNull(d.address_country_id,''))
OR(isNull(p.client_printer_id,'')<>IsNull(d.client_printer_id,'')))
View 2 Replies
View Related
Apr 27, 2004
Hi ,
I am trying to run DTS package (stored on SQL Server) using Visual basic but i am getting the following error
Runtime error '-2147217843 (80040e4d)'
Login failed for 'MyUserID'
*************************************
i used the following code in VB program
Sub Command1_Click()
Dim dtsp As New DTS.Package
dtsp.LoadFromSQLServer _
ServerName:="MyServer", _
ServerUserName:="MyUserID", _
ServerPassword:="MyPassword", _
PackageName:="DTSDemo"
dtsp.Execute
End Sub
*************************************
I can Run the package direct from SQL server but get error by Vb program. Any idea why it is so.
Thanks
View 3 Replies
View Related
May 24, 2004
This is my procedure and the error is incorrect syntax near '01'
DECLARE @returnDay int
--Looking at current date,
SELECT @returnDay = DatePart(day,GetDate())
--If is the 7th of the current moth then
If @returnDay = 24
EXEC master.dbo.xp_sendmail
@query = 'SELECT a.HospitalName,a.HospitalCode,c.ProductName,b.UnitsDiscarded,d.FateOfProducts,b. DateEntered,
b.DateCompleted,b.CompiledBy FROM test.dbo.Units b inner join Hospitals a ON (a.HospitalID = b.HospitalID)
inner join Products c ON (b.ProductID = c.ProductID)
inner join FateOfProducts d ON (d.FateID = b.FateID)
where b. DateEntered = DateAdd(month, -1, Convert(CHAR(8), GetDate(), 121) + '01') order by a.HospitalID',
@recipients=test@hotmail.com', @message='Submitting Results for the previous month',
@subject=' results for previous month', @attach_results = 'true', @separator = '/s'
SELECT @@ERROR As ErrorNumber
What am I missing here now, I am quite new to stored procedures
REgards
View 12 Replies
View Related
Jan 26, 2007
Can any one please help explain why this error has happened, it is not a normal error of SSIS,
"SSIS Debug host has encountered a problem and needs to close. We are sorry for the inconvenience"
It has 2 buttons Debug and Close, this error happened in the middle of a script task.
View 1 Replies
View Related
Nov 6, 2007
Hello,
We have a self-written procedure to restore transaction logs on a standby server (Sql Server 2000 sp4)
We do this by joining 2 msdb tables, to find out which backups have been performed: backupmediafamily and backupset.
Sometimes backups are NOT registred in table msdb..backupmediafamily.
Underneath 2 examples.
OK- underneath queries shows the time the backup was created in the physical_device_name; joined with media_set_id
99% shows these correct data
select media_set_id, physical_device_name from backupmediafamily where media_set_id = 258716
media_set_id physical_device_name
258716 H:Mssql2000MSSQLBACKUPPAPPS10_tlog_200701010030.TRN
select media_set_id, backup_start_date , backup_finish_date, database_name from backupset where media_set_id = 258716
media_set_id backup_start_date backup_finish_date database_name
258716 2007-01-01 00:30:08.000 2007-01-01 00:30:08.000 PAPPS10
NOT ok
select media_set_id, physical_device_name from backupmediafamily where media_set_id = 376467
media_set_id backup_start_date backup_finish_date database_name
376467 2007-02-17 09:00:14.000 2007-02-17 09:00:14.000 PDBTIME
376467 2007-10-31 19:15:05.000 2007-10-31 19:15:05.000 PJAVA
select media_set_id, backup_start_date , backup_finish_date, database_name from backupset where media_set_id = 376467
media_set id physical_device_name
376467 H:Mssql2000MSSQLBACKUPPDBTIME_tlog_200702170900.TRN
!!! No record for backup transaction log database PJAVA
select media_set_id, physical_device_name from backupmediafamily where physical_device_name like '%PJAVA%2007103119%'
media_set_id physical_device_name
1115347 H:Mssql2000MSSQLBACKUPPJAVA_tlog_200710311900.TRN
1115432 H:Mssql2000MSSQLBACKUPPJAVA_tlog_200710311930.TRN
1115475 H:Mssql2000MSSQLBACKUPPJAVA_tlog_200710311945.TRN
Missing record for backup made on 2007-10-31 19:15 hours !!!!
Hope somebody can help me.
Best regards,
hvdtol
View 11 Replies
View Related
Jun 28, 2004
Hello,
My network team accidentally deleted and had to recreate the WNS database on the network, which posed all sorts of problems for us. Most everything is corrected, however I get the following error message in the failure of the database backup maintenance plan:
--------------------------------------------------------------------------
The job failed. Unable to determine if the owner (ANCONYCOgnos) of job DB Backup Job for DB Maintenance Plan '6pm Nightly Production Backup' has server access (reason: Could not obtain information about Windows NT group/user 'ANCONYCOgnos'. [SQLSTATE 42000] (Error 8198)).
--------------------------------------------------------------------------
I tried even adding this user into SQL Sever with full rights and it still did not work. It worked fine before hundreds of times, and like I said only stopped working when my network team did some thing on WNS.
Does anyone know what may be causing this. Is there something that they may have to add back to the network?
Any help or direction for additional research is greatly appreciated.
Thanks.
Rodney
View 1 Replies
View Related
Oct 26, 2007
When im testing in local machine... my app works fine... but when i publish it on server... the sql DateTime parameter get an error:
ERROR ON SERVER : String was not recognized as a valid DateTime
my code:SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["StringDeConexao"].ConnectionString);
SqlCommand oCmd = new SqlCommand("spcCadLjItem", con);oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Connection.Open();SqlTransaction trans = con.BeginTransaction();
oCmd.Transaction = trans;
oCmd.Parameters.Add(new SqlParameter("@dt_exclusao", SqlDbType.DateTime));
oCmd.Parameters["@dt_exclusao"].Value = DBNull.Value;
oCmd.ExecuteNonQuery();
When I inspect the type of parameter on my machine its ok.. SqlDbType its DateTime... and runs perfectly...Why it doesnt work when i publish on server???????
tks!!
View 1 Replies
View Related
Mar 27, 2002
Hi Everybody,
I am getting this error when I try to bcp in or even when
I try to create a Primary key or index on a Table.
- Unable to create index 'PK_CMCMessages'.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]
Backup, CHECKALLOC, bulk copy, SELECT INTO, and file
manipulation (such as CREATE FILE) operations on a
database must be serialized. Reissue the statement
after the current backup, CHECKALLOC, or file manipulation
operation is completed.
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not
create constraint. See previous errors.
I ran CHECKALLOC and its running for days and I dont have
any clue whats happening. If you have any idea please let
me know how to solve this problem.
tks in advance,
Sri
View 4 Replies
View Related
Jul 25, 2015
receive an error: "Cannot perform a differential backup for database ..., because a current database backup does not exist." Can't fully understand what to do with this.
View 2 Replies
View Related
Jun 4, 2008
hi
i have restore database use backup file in another machine of same name of database there following error
TITLE: Microsoft SQL Server Management Studio
------------------------------
Restore failed for Server 'database name'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
The backup set holds a backup of a database other than the existing 'dbname' database.
RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 3154)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1399&EvtSrc=MSSQLServer&EvtID=3154&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
View 1 Replies
View Related
Jul 6, 2015
Had a recent drive failure on or server. Subsequently Our sql database failed to backup. Ran dbcc checkdb and got the following errors:
Msg 8966, Level 16, State 2, Line 1
Unable to read and latch page (1:241724) with latch type SH. 1(Incorrect function.) failed.
Msg 2533, Level 16, State 1, Line 1
Table error: page (1:241724) allocated to object ID 370100359, index ID 3, partition ID 868679827259392, alloc unit ID 868679827259392 (type In-row data) was not seen. The page may be invalid or may have an incorrect alloc unit ID in its header.
[Code] .....
View 5 Replies
View Related
Mar 5, 2004
Hello,
I can't get bcp to run on any database but 'master'. I get a 'failed to login' error. i'm logged in as 'sa' with full permissions.
Please help
Thanks
View 3 Replies
View Related
Jan 31, 2008
Hi there
I'm getting this message on my third automated backup of the transaction logs of the day. Both databases are in full recovery mode, both successfully backed up at 01.00. The transaction logs backed up perfectly happily at 01:30 and 05:30, but failed at 09:30.
The only difference between 05:30 and 09:30's backups is that the log files were shrunk at 08:15 (the databases in question are the ones that sit under ILM2007, and keeping the log files small keeps the system running better).
Is it possible that shrinking the log files causes the database to think that there hasn't been a full database backup?
Thanks
Jane
View 3 Replies
View Related
Dec 16, 2005
Hi,
I am using Sql database in my asp.net application. the code runs fine on the machine where i m developing but when I try to run the code on other machine it gives following error--
error is related to access to database.(sql personal server is installed on local machine) I m giving the following connection string---
"Server=localhost;UID=sa;PWD=mypassword;Database=try1"
I have reinstalled the sql server using mixed mode authentication and the same sa password but still problem continues..
THE ERROR IT GIVES IS---
Server Error in '/try1' Application.
SQL Server does not exist or access denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.Source Error:
Line 49: SqlCommand cmdSelect;
Line 50: cmdSelect = new SqlCommand("select * FROM Departments", sqlConn);
Line 51: sqlConn.Open();
Line 52: return cmdSelect.ExecuteReader(CommandBehavior.CloseConnection);
Line 53: }Source File: c:inetpubwwwroot ry1DataAccessCode.cs Line: 51 Stack Trace:
[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction)
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()
try1.DataAccessCode.getDept() in c:inetpubwwwroot ry1DataAccessCode.cs:51
try1.WebForm1.Page_Load(Object sender, EventArgs e) in c:inetpubwwwroot ry1Login.aspx.cs:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
View 3 Replies
View Related
May 19, 2015
Backing up all databases on a sql server that hosts secondary high availability databases as well as other databases. The other databases back up fine, but the high availability secondaries all get the same error:
BackupDiskFile::OpenMedia: Backup device 'F:MSSQLBackupdbnamedbname_backup_2015_MM_DD_tttttt_ttttttt.bak' failed to open. Operating system error 2(The system cannot find the file specified.)
View 11 Replies
View Related
Oct 12, 2007
Hi,
I drag the database Backup Task from the toolbox and double-click on it, it shows this error:
Cannot show the editor for this task.
Additional information
Method not found: 'Void Microsoft.SQLServer.Management.DatabaseMaintenance.TaskUIUtils..ctor()'.
(Microsoft.SQLServer.MaintenancePlanTasksUI)
What is the prob with this?
cherriesh
View 1 Replies
View Related
Oct 9, 2001
I have a stored proceedure (which I will tag on at the end for those interested) which is taking at least 15 minutes to run when executed, but completes in 1 minute when the tsql statement is run in Query Analyser. Why is this?
I suspect that it may be connected to table indexing, but why then is this bypassed when QA is used?
Any advice appreciated.
Derek
************************************************** ***********************
IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'dbo.sp_ValidateAIGL') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE dbo.sp_ValidateAIGL
GO
CREATE PROCEDURE dbo.sp_ValidateAIGL
@IGLPeriodIDInt,
@IGLProgramIDInt
AS
/* ************************************************** ************************
Name:sp_ValidateIGL
Author:CL
Date:19-Jan-2001
Notes:
************************************************** ************************ */
--SET NOCOUNT ON
DECLARE@TaxYearChar(5),
@FrequencyChar(1),
@PeriodNo Int,
@ProgramLogIDInt
SELECT@TaxYear = TaxYear,
@PeriodNo = PeriodNo,
@Frequency = Frequency
FROMtbl_IGLPeriods
WHEREIGLPeriodID = @IGLPeriodID
SELECT @ProgramLogID = (SELECT ProgramLogID FROM tbl_SYSProgramLogs WHERE IGLProgramID = @IGLProgramID AND IGLPeriodID = @IGLPeriodID)
CREATE TABLE #IGLErrors
(
KeyFieldChar(24),
ErrorIDInt,
DescriptionVarChar(255)
)
-- *** Global Non Program Specific Data Errors ***
-- CHECK - that there are records in the DEB_IGL_PAYROLL_OUTPUT file.....none and the routine failed...
IF NOT EXISTS(SELECT * FROM tbl_OUT_Payroll WHERE IGLProgramID = @IGLProgramID)
INSERT INTO #IGLErrors SELECT NULL, 100, 'No records were processed by the IGL run!'
SELECT * FROM #IGLErrors
-- CHECK - search for any records where the employee's EXPENSE_CODE is NULL
INSERT INTO #IGLErrors
SELECT DISTINCT
NULLIF(EmpNo, ''),
2,
'Employee "' + COALESCE(NULLIF(RTRIM(EmpNo), ''),
'<Missing Employee>') + '" (Organisation Unit - ' + COALESCE(RTRIM(OrgUnitCode),
'<No Organisation Unit>') + ') does not have a EXPENSE_CODE Code.'
FROM tbl_OUT_Payroll
WHERE NULLIF(ExpenseCode, '') IS NULL
ANDIGLProgramID = @IGLProgramID
SELECT * FROM #IGLErrors
-- CHECK - check that the BALANCE of DEBITs match the balance of CREDITs
IF (SELECT SUM(Cash) FROM tbl_OUT_Payroll WHERE IsCredit = 1 AND IGLProgramID = @IGLProgramID) <> (SELECT SUM(Cash) FROM tbl_OUT_Payroll WHERE IsCredit = 0 AND IGLProgramID = @IGLProgramID)
INSERT INTO #IGLErrors SELECT NULL, 3, 'The total cash value for DEBIT elements does not match the total cash for CREDIT elements.'
SELECT * FROM #IGLErrors
-- *** Program 1 and 2 errors ***
IF @IGLProgramID IN (1, 2)
BEGIN
-- CHECK - search for any records where the employee's COST_CENTRE is NULL
INSERT INTO #IGLErrors
SELECT DISTINCT
NULLIF(EmpNo, ''),
1,
'Employee "' + NULLIF(RTRIM(EmpNo), '') + '" (Organisation Unit = ' + RTRIM(OrgUnitCode) + ') does not have a COST_CENTRE Code.'
FROM tbl_OUT_Payroll
WHERE NULLIF(CostCenter, '') IS NULL
ANDIGLProgramID = @IGLProgramID
SELECT * FROM #IGLErrors
-- Check for EMPLOYEEs that were not transfered to the PAYROLL output (usually caused by missing ORG_UNITs or not picked up in
-- the DEB_VIEW_APPOINTEE view...)
INSERT INTO #IGLErrors
SELECT DISTINCT
EMP_NO,
11,
'Employee "' + RTRIM(EMP_NO) + '" was excluded from the summary. Check their Organisation Unit codes!'
FROM PSELive.dbo.COSTING_OUTPUT
WHERENOT EMP_NO IN (SELECT DISTINCT EmpNo FROM tbl_OUT_Payroll WHERE IGLProgramID = @IGLProgramID)
ANDPERIOD_NO = @PeriodNo
ANDTAX_YEAR = @TaxYear
SELECT * FROM #IGLErrors
-- Check that there are no ELEMENTS in the COSTING_OUTPUT table that don't exist in the tbl_IGLElements table
INSERT INTO #IGLErrors
SELECT DISTINCT
ELEMENT,
12,
'Element "' + RTRIM(ELEMENT) + '" does not exist in the IGL Interface Elements table!'
FROM PSELive.dbo.COSTING_OUTPUT
WHERE ELEMENT NOT IN
(
SELECT DISTINCT Element
FROM tbl_IGLElements
)
ANDPERIOD_NO = @PeriodNo
SELECT * FROM #IGLErrors
END
-- *** Add a error to indicate the number of errors ***
IF EXISTS (SELECT * FROM #IGLErrors)
INSERT INTO #IGLErrors
SELECT 0,
0,
'Warning, there are ' + CAST(Count(*) AS VarChar(5)) + ' recorded errors!'
FROM#IGLErrors
-- Transfer the records to the ErrorsLog table ready for the user to view...
DELETE FROM tbl_SYSErrorsLog
INSERT INTO tbl_SYSErrorsLog (IGLProgramID, OutputLogID, KeyField, ErrorID, Description)
SELECT@ProgramLogID,
@IGLPeriodID,
KeyField,
ErrorID,
Description
FROM #IGLErrors
ORDER BY ErrorID
DROP TABLE #IGLErrors
SELECT *
FROM tbl_SYSErrorsLog
ORDER BY ErrorID
--SET NOCOUNT OFF
GO
GRANT EXECUTE ON dbo.sp_ValidateAIGL TO Public
GO
View 2 Replies
View Related
Jun 6, 2007
i have the following step in a stored procedure
Alter table ABC
Add constraint Primary_KEY_ABC
PRIMARY KEY (DATE, Amount)
but i get the error primary key already exists.
So is there any way I can generate a unique name everytime I run the
proc, its runs only once a day so can i use getdate() in the name somehow. is it possible.
Ashley Rhodes
View 4 Replies
View Related
Nov 13, 2014
I have one drop and create procedure script in one sql session and execute the procedure in other session. Now when i am compiling the procedure in first session, it gets completed successfully.
Now when i move to other session and try to execute the procedure, it gives me error saying :
"Invalid column name 'ColumnName'."
Now when I execute the procedure in same session in which procedure was compiled, it runs successfully. Once run, I go back to my other session and it runs again.
View 9 Replies
View Related
Apr 25, 2007
Iam trying to backup my database but nothing is backedup and no error message is displayed. Here is my code.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Net.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim con As SqlConnection
con = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|safetydata.mdf;Integrated Security=True;User Instance=True")
Dim com As New SqlCommand("BACKUP DATABASE safetydata TO c:ackuptest")
com.Connection = con
com.Connection.Open()
com.ExecuteNonQuery()
com.Connection.Close()
Response.Redirect("DeveloperBackup_success.aspx")
Catch ex As Exception
Response.Redirect("~Developerackup_error.aspx")
End Try
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>BackUP Page</title>
View 3 Replies
View Related