Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12554 articles
Browse latest View live

SQL 2012 trigger inexplicably not executing when table modified by another trigger

$
0
0

I have a table with an after-trigger with code to update a summary field:

CREATE TRIGGER [dbo].[Service_Update]
   ON  [dbo].[Service]
   AFTER UPDATE
AS 
BEGIN
	SET NOCOUNT ON;
	IF Trigger_NestLevel() >= 2 RETURN

	IF EXISTS (SELECT 1 FROM inserted)
	BEGIN
		MERGE dbo.Service AS target
		-- select-statement simplified for brevity
		USING (SELECT i.UID, i.JobCode + ' ' + i.City + ': ' + Count(od.OrderUID) AS Summary
			FROM inserted i
			INNER JOIN dbo.Service s ON i.UID = s.UID
			INNER JOIN dbo.OrderDetail od ON i.UID = od.OrderUID
			GROUP BY od.OrderUID)
			AS source (UID, Summary)
			ON (target.UID = source.UID)
			WHEN MATCHED THEN
				UPDATE SET Summary = source.Summary;
	END
END


The Service_Update trigger works as expected when changes are made to records in the Service table.

When changes are made to a child table, dbo.OrderDetail, such that the number of records linked to the parent table, dbo.Service, changes, I want to have the trigger on the Service table execute to update the summary line.

This trigger is on the OrderDetail table:

CREATE TRIGGER OrderDetail_Update
   ON dbo.OrderDetail
   AFTER INSERT, UPDATE, DELETE
AS 
BEGIN
	-- Touch the Service table to cause the summary line to  -- get updated if a record has been added or removed. 
	MERGE dbo.Service AS target
	USING (SELECT OrderUID FROM inserted
		GROUP BY OrderUID
	UNION SELECT OrderUID FROM deleted
		GROUP BY OrderUID) AS source (OrderUID)
	ON (target.UID = source.OrderUID)
	WHEN MATCHED THEN
		UPDATE SET Note = Note;
END

When changes are made to the OrderDetail table, the OrderDetail_Update trigger executes. This trigger makes trivial updates to the associated records in the Service table. Unfortunately, even though the records in the Service table get updated, the trigger on the Service table does not execute.

I have confirmed that the code in the OrderDetail_Update trigger is being executed. If I manually execute equivalent commands (I can't execute the actual commands because the inserted and deleted tables only exist within the trigger) the Service_Update trigger executes as expected.

I thought that the issue might be that SQL Server is smart enough to figure out that setting a field to its existing value does not actually change anything and hence SQL Server skips the operation. However, as a test I tried changing the update-command to say, "SET Note = IIF(Note is null, '', null)" to ensure that the value gets set to something different but it did not fix things.

Is there some reason why changes made to a table originating from code executing in a trigger would not cause a trigger on the table to fire? Is there any other obvious reason why the above scheme would not work?

I am running SQL Server 2012 SP1 Standard Edition, 64-bit.


SQL Server 2000 auditing/tracking DML changes on specific tables.

$
0
0

Hello,

We would like to audit/track all DML activities on couple of tables which reside on SQL Server 2000. Triggers are an option we think but thought that would impact performance because of activity on those tables. Could someone please suggest any other best options that are possible with SQL Server 2000 to capture these changes.

Thanks,

SQL Server 2000 auditing on DML changes on user tables to user databases

$
0
0
Please let me know if you know if there is any procedure or steps to determine DML changes on user tables in database.

sql server 2012 evaluation edition expired

$
0
0

Hi Gurus,

 sql server 2012 evaluation edition expired,

Here i don't have any backups and when i browsed few blogs suggest to upgrade to another edition from Evaluation edition.

1)Do upgrading the edition keeps all  the user databases the same and how about the logins and jobs and other data in system databases.

2) Am having a developer edition 2012 can i attach the data files ( .mdf ) to the instance using attach database method from Evaluation Edition Instance 2012   to    Developer Edition 2012.

3)If i uninstall the Evaluation edition 2012 can i have any loss of data.

4)Please suggest me the best practice if any thing available.

Thanks in advance..

There is insufficient system memory in resource pool 'internal' to run this query

$
0
0

hello Everyone,

today i am getting one error while opening activity monitor.

i am unable to open AM and i checked in sql server error log i received error message description about memory dump.

below mentioned message. 

There is insufficient system memory in resource pool 'internal' to run this query...

Double row added from a source table, that did not have the double record

$
0
0

Dear All

I was wondering if someone could give me some further information on the following error that we saw in one of processes. Every night we connect to a remote server using Linked Server and copy details from that database to a loading table, then load it into the 'real' table in our own environment. The remove database we load it from has indexes/primary keys that match the 'real', however the 'loading' table itself does not have any indexes or primary keys, both are SQL Server 2005 machines.

In the loading table we first of all truncate it then do a select insert statement from the remote server, then we then truncate the 'real' table and load iit from the 'loading' table.

The issue is when we attempted to load it into our 'real' table from our loading table there was a duplicate row, and our process failed with a Primary Key violation.

I checked the source with does have the same primary key's in, it did not contain a duplicate row and I checked the loading table and that did contain a duplicate row.

My question this is in what circumstances this could happen ?

Thanks

J

The SQL Server (Instance Name) service terminated unexpectedly. It has done this 4 time(s).

$
0
0

Our SQl server 2012 instance terminated unexpectedly many times in last two months. We had a look the error log but there is nothing details in the log. And there is nothing in the Windows event viewer. And i did run checkdb to all databases and there is no corrupt database. And it is happing in a random time, Could anyone advice on this, please.

Many thanks

syspolicy_purge_history Job; step 3 failure Powershell

$
0
0

Hi guys,

the syspolicy job is failing on two of my instances, it seems that it cannot find sqlps.exe.  I went into the registry and noticed that the following registry entry is missing "Microsoft.SqlServer.Management.PowerShell.sqlps110"

On the systems where the job works, the entry is there.  

My questions are: 

Do you guys have any idea why this would be missing?

What's the best/safest way to add this if in fact that's the reason it's failing.

Thanks in advanced.




We start getting intermittence error in our application web server when calling a store proc in sql server. this problem seems happened after our OS upgrade to 2008 R2.

$
0
0

We start getting intermittence error in our application web server when calling a store procedure in sql server(the store proc use linked server to access another server.   From application server, user got the following Exceptions, and when I did profiler trace in our sql server side, I got the OLEDB error:

<hresult>-2147467262</hresult>

Is anybody seeing this type of issue?   User/developer claims that this error happened after our Server operation group did the OS upgrade to window server 2008 R2.   I enabled the 'allow inprocess' in the SQLOLEDB linked server provider, but that did not help.   Any response is great appreciated.

Is there any hotfixes that we need to apply for the OS upgrade?  Our database is still in sql server 2005 SP4.  the OS was upgraded from window 2003 to window 2008 R2.

Exceptions
System.Web.HttpUnhandledException
Untrapped Exception: Exception of type   'System.Web.HttpUnhandledException' was thrown.
at   System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,   Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&   completedSynchronously)
Unknown
System.NullReferenceException
Object reference not set to an instance of an object.
at   USG.CRMApplications.DataAccessLayer.ProductDC.GetProduct(String   commodityCode, String suffix) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\ProductDC.vb:line 157
  at USG.CRMApplications.DataAccessLayer.QuoteDC.LoadQuote(String referenceNum,   Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\QuoteDC.vb:line 1484
  at USG.CRMApplications.DataAccessLayer.QuoteDC.TryLoad(String referenceNum,   JobCustomerQuoteDTO& individualQuote, GroupQuoteDTO& groupQuote,   Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\QuoteDC.vb:line 827
  at   USG.CRMApplications.Application.QuoteModule.Services.QuoteAppService.CheckAccess(UserDTO   user, String referenceNum, Int32 version) in   C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications\QuoteModule\Services\QuoteAppService.vb:line   242
  at CRM_Web_Applications.view.ValidateAccess(String referenceNumber, Guid   groupId, Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\CRM Web Applications\quotes\view.aspx.vb:line 302
  at CRM_Web_Applications.view.Page_Load(Object sender, EventArgs e) in   C:\DEVELOPMENT\CRMWebApplications\CRM Web Applications\CRM Web   Applications\quotes\view.aspx.vb:line 55
  at System.Web.UI.Control.LoadRecursive()
  at System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
C:\DEVELOPMENT\CRMWebApplications\CRM   Web Applications\USG.CRMApplications.DataAccessLayer\ProductDC.vb
157

Li-hui Chen

We start getting intermittence error in our application web server when calling a store proc in sql server. this problem seems happened after our OS upgrade to 2008 R2.

$
0
0

We start getting intermittence error in our application web server when calling a store procedure in sql server(the store proc use linked server to access another server.   From application server, user got the following Exceptions, and when I did profiler trace in our sql server side, I got the OLEDB error:

<hresult>-2147467262</hresult>

Is anybody seeing this type of issue?   User/developer claims that this error happened after our Server operation group did the OS upgrade to window server 2008 R2.   I enabled the 'allow inprocess' in the SQLOLEDB linked server provider, but that did not help.   Anything response is great appreciated.

Is there any hotfixes that we need to apply for the OS upgrade?  Our database is still in sql server 2005 SP4.  the OS was upgraded from window 2003 to window 2008 R2.

Exceptions
System.Web.HttpUnhandledException
Untrapped Exception: Exception of type   'System.Web.HttpUnhandledException' was thrown.
at   System.Web.UI.Page.HandleError(Exception e)
  at System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,   Boolean includeStagesAfterAsyncPoint)
  at System.Web.UI.Page.ProcessRequest()
  at System.Web.UI.Page.ProcessRequest(HttpContext context)
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&   completedSynchronously)
Unknown
System.NullReferenceException
Object reference not set to an instance of an object.
at   USG.CRMApplications.DataAccessLayer.ProductDC.GetProduct(String   commodityCode, String suffix) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\ProductDC.vb:line 157
  at USG.CRMApplications.DataAccessLayer.QuoteDC.LoadQuote(String referenceNum,   Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\QuoteDC.vb:line 1484
  at USG.CRMApplications.DataAccessLayer.QuoteDC.TryLoad(String referenceNum,   JobCustomerQuoteDTO& individualQuote, GroupQuoteDTO& groupQuote,   Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications.DataAccessLayer\QuoteDC.vb:line 827
  at   USG.CRMApplications.Application.QuoteModule.Services.QuoteAppService.CheckAccess(UserDTO   user, String referenceNum, Int32 version) in   C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\USG.CRMApplications\QuoteModule\Services\QuoteAppService.vb:line   242
  at CRM_Web_Applications.view.ValidateAccess(String referenceNumber, Guid   groupId, Int32 version) in C:\DEVELOPMENT\CRMWebApplications\CRM Web   Applications\CRM Web Applications\quotes\view.aspx.vb:line 302
  at CRM_Web_Applications.view.Page_Load(Object sender, EventArgs e) in   C:\DEVELOPMENT\CRMWebApplications\CRM Web Applications\CRM Web   Applications\quotes\view.aspx.vb:line 55
  at System.Web.UI.Control.LoadRecursive()
  at System.Web.UI.Page.ProcessRequestMain(Boolean   includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
C:\DEVELOPMENT\CRMWebApplications\CRM   Web Applications\USG.CRMApplications.DataAccessLayer\ProductDC.vb
157

Li-hui Chen

Intermittent connection failures to the database. SQL is 2008R2 + SP2

$
0
0
The application login is facing intermittent connection failures. When this happens they try to connect back and it works. There are no errors at the SQL Server end. I'd like to use profiler or perfmon to check the failure. Can someone let me know what specific counters related to connections that we can use to check. And also some suggestions on how to go about troubleshooting this.

There is insufficient system memory in resource pool 'internal' to run this query.

$
0
0

Hello Everyone,

in sql server error log i found below given error with heavy messages and i am unale to open Activity Monitor.

error:

There is insufficient system memory in resource pool 'internal' to run this query.

enviornment is

windows server 2008 R2 64 bit,

sql server 2008 R2 64 bit,

RAM :16 GB

processors:24

As per RAM i assigned Max Server Memory:13107.


mastanvali shaik

List of Severity 1,Severity 2, Severity 3 issues in SQL Server

$
0
0

Hi Team ,

I am working as SQL DBA. 

I would like to know list of Severity 1,Severity 2, Severity 3 issues in SQL Server. I request you to provide these details ASAP.

Examples :

---------------------

Severity 1 issue :

-----------------------------

1)SQLServer \ SQL ClUSTER is down 

2) DB is corrupted\damaged\deleted

Severity2 issue :

-----------------------------

1)Tempdb is full

2)Tlog is full

Severity 3 issue :

-----------------------------

1)Job failed 2) Package execution failed.

Like above I would like to know more list of  severity 1,2,3 and 4 issues in sqlserver . Please post list of severity issues in SQLServer .

Thanks and Reards,

Venkat

Shifting column data after a pivot

$
0
0

After creating data from a pivot I would like to shift the data to the left. 

Example:

Data after pivot

1, 2, 10, NULL, NULL, NULL, NULL, NULL, 29

2, 2, NULL, NULL, NULL, NULL, NULL, NULL, 29

3, 2, NULL, NULL, NULL, 15, NULL, NULL, 29

Data needed

1, 2, 10, 29, NULL, NULL, NULL, NULL, NULL

2, 2, 29, NULL, NULL, NULL, NULL, NULL, NULL

3, 2, 15, 29, NULL, NULL, NULL, NULL, NULL

The data are IDs in another table that will be used further down the procedure.  Maybe code needs to be changed in the PIVOT but I do not know.


SQL Server 2014 reseting isolation level

$
0
0

Hi,

Working with C# application accessing SQL Server 2012 and 2014 using ADO.NET.

There seem to be a change regarding isolation level reset when returning connection to pool.

Previous versions of SQL Server does not reset the isolation level on the connection (unfortunately) as claimed here (http://support.microsoft.com/?id=972915).

However it seems this has changed with SQL Server 2014.

If running the attached code it shows that the isolation level in fact is reset when running against a SQL Server 2014 instance but not 2012.

Can anyone on the SQL Server team confirm that this is an intended change that is here to stay? I have not seen any documentation on this so far in the behavior changes documented here: http://msdn.microsoft.com/en-us/library/ms143359.aspx

    class Program
    {
        static void Main(string[] args)
        {
            //AsyncTest.CallAsyncMethod_RunsInSeparateThread();
            TestIsolationLevelReset();
            Console.ReadLine();
        }

        public static void TestIsolationLevelReset()
        {
            var connectionString = @"Data Source=(local); Integrated Security=true; Initial Catalog=master;";
            var commandText = @"select cast (transaction_isolation_level as nvarchar) + ' - ' + CAST(@@spid as nvarchar) from sys.dm_exec_sessions where (session_id = @@SPID)";

            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                var cmd = new SqlCommand(commandText, conn);
                Console.WriteLine(cmd.ExecuteScalar());
            }

            using (var tran = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.Serializable }))
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                var cmd = new SqlCommand(commandText, conn);
                Console.WriteLine(cmd.ExecuteScalar());

                tran.Complete();
            }

            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();

                var cmd = new SqlCommand(commandText, conn);
                Console.WriteLine(cmd.ExecuteScalar());
            }
        }
    }


I/O on SQL server

$
0
0

Hi all, 

My SAN is taking more time for Backup (native) with no compress  where as on DAS  (10% of the time  of SAN ) it takes a very less time to complete.

Is there as way to see what is happening on the Storage , is there any way to TEST the DAS and SAN storage via SQL Server ..

Please help it is very urgent .. 

Thanks & regards 

K.Muthus 


k.muthus

SQL Server Memory settings versus Locked Pages in Memory

$
0
0
(min srv memory=0 & max srv memory=48GB),(min srv memory=12GB & max srv memory=48GB) any diff in terms of locked page in memory?

now let me explain my question including some internals...

whenever we are using LPIM then memory for buffer pool will be allocated through AWE API function AllocateUserPhysicalPages().Memory allocated through this function will not be a part of process working set and can not be pagedout.we also knows that min and max memory settings belongs to buffer pool part only.

Now come back to my question - (min srv memory=0 & max srv memory=48GB) and (min srv memory=12GB & max srv memory=48GB) with LPIM
here all memory upto 48 GB will allocated through AllocateUserPhysicalPages() function that will not be a part of sql server process working set and also can not be paged out.

i.e. all memory allocated to buffer pool can not be paged out due to LPIM i.e. 48gb in my case.

then how can we say that with LPIM, SQL Server can not paged out this memory upto only min server memory?

SQL Server Locking Mechanism...

$
0
0
lets say we have a table on disk. duing a transaction a single row will be modified. so that page will go in memory.

Now as per locking SQL Server will apply IX lock on table level also while table is not inside the memory, then how SQL Server will manage locking for that table which in not inside memory (only a single page of that table is in the memory)?

is this due to metadata of that table? then what will be the internal working for this?

SQL Server 2000 auditing on DML changes on user tables to user databases

$
0
0
Please let me know if you know if there is any procedure or steps to determine DML changes on user tables in database.

Adobe Illustrator thumbnail view in a Picture Library?

$
0
0

We are using Adobe Illustrator and we need to see the thumbnails in a picture library.  All of the other images work, but not the AI files.  

We got the 16x16 icons added for AI for the details view, but we haven't been able to figure out where the thumbnail's are generated from.  Searching the internet hasn't worked yet, (must not have the right combination of search words), so I'm hoping that someone here can offer some suggestions.

If anyone knows how to do this I would greatly appreciate hearing it.

Thanks.

Ted

Viewing all 12554 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>