Server Trigger Timing Out Access Append Query

Oct 17, 2013

I have a SQL Server database running on a local PC which will eventually be scaled up once everything is working.

The Database takes data from an Access database, then the SQL Server aggregates this data into several other tables.

I have used a trigger to run this in SQL Server, once a table in SQL Server is appended with a specific value.

I have tested the trigger to do a simple task, and this works.

I have tested the aggregation query which create 18 seperate tables as well. It takes around 25 minutes to run. These are huge tables

When I use Access to append the final value to start the SQL Server trigger it freezes and eventually times out. I assume this is because it is running the 25minute trigger, and Access has to wait until this is completed before it can proceed.

I was hoping it would trigger SQL Server to run the trigger, then Access could go off and do something else!

View 10 Replies


ADVERTISEMENT

Help With Access Append Query To Ms Sql

Feb 21, 2006

hi,
I am in the process of creating an append query that sends the fields of an open form from my ms access 2000 db to a table in ms sql 2000. I've successfully linked the ms sql tables and created the query to pull data from my form but when i run the append i get a key violation error and nothing gets appended. I know which field is the primary key in ms sql i just don't know how to change my access table to suit, any ideas?

To start I've made my append query simple and it just pulls the contact name. Here's my sql statement if that helps.
CODE
INSERT INTO dbo_PatientMaster ( PatientFirstName, PatientLastName, PatientAccountNumber )
SELECT [Forms]![Contacts]![FirstName] AS Firstname, [Forms]![Contacts]![LastName] AS [Last], [Contacts]![PatientAccountNumber] AS [Patient Account Number]
FROM Contacts, dbo_PatientMaster
GROUP BY [Forms]![Contacts]![FirstName], [Forms]![Contacts]![LastName], [Contacts]![PatientAccountNumber];
In access the patient account number is empty and I just created that field in my access table today.

thanks in advance

View 6 Replies View Related

Append Query From Access Table To Linked SQL Server Table Failing

Jun 18, 2004

Strange one here - I am posting this in both SQL Server and Access forums

Access is telling me it can't append any of the records due to a key violation.

The query:

INSERT INTO dbo_Colors ( NameColorID, Application, Red, Green, Blue )
SELECT Colors_Access.NameColorID, Colors_Access.Application, Colors_Access.Red, Colors_Access.Green, Colors_Access.Blue
FROM Colors_Access;

Colors_Access is linked from another MDB and dbo_Colors is linked from SQL Server 2000.

There are no indexes or foreign contraints on the SQL table. I have no relationships on the dbo_ table in my MDB. The query works if I append to another Access table. The datatypes all match between the two tables though the dbo_ tables has two additional fields not refrenced in the query.

I can manually append the records using cut and paste with no problems.

I have tried re-linking the tables.

Any ideas?
Thanks,
Brad

View 4 Replies View Related

Append Query Problems, From Access To Excel

Feb 27, 2003

Hi everyone. I have a problem with an append query runing from a small Access database and would very much appreciate some input.

The append query from Access is as follows:

INSERT INTO TransferTable ( Name, Surname, Company, Address1, Address2, [Town/City], County, PostCode, Phone, Fax, Email, [Client type] )
SELECT [Clients].[Name], [Clients].[Surname], [Clients].[Company], [Clients].[Address 1], [Clients].[Address 2], [Clients].[Town/City], [Clients].[County], [Clients].[Post Code], [Clients].[PhoneNumber], [Clients].[FaxNumber], [Clients].[Email Address], [Clients].[ClientType]
FROM Clients
WHERE [Name]=[Forms]![Client Form]!Name;

This works up to a point. What it does is send the selected data to the TransferTable which is a link table to a sheet in an Excel workbook.

So far so good.

Each time the query is run though, it inserts the selectd data on the line below the previous run, even if the information that was inserted last time was not saved. So on the first run the query will drop the desired information into row A2 of the TransferTable, then even if that is deleted and the changes to the workbook are not saved, the next time the query is run it goes down to row A3, then A4 and so on. no doubt this is the exact point of an append query, but it's really aggravating me.

What I'd like is a query that will get the data into the same row of the TransferTable each time it is run, since another sheet in the Excel workbook runs some calculations based on the data held in the cells of the TransferTable sheet.

I've tried the SQL editor in Excel, but my very limited knowledge has left me completely frustrated. Does anyone have any ideas how I can achieve this outcome before I go completely nuts ?

I don't mind if the query runs from Excel or Access.

Thanks in advance to anyone who offers any input.

View 1 Replies View Related

MS Access Append Query To SQL Table Problem

Sep 22, 1998

Any known problems with using an Access Append query to add data to an SQL table?

View 1 Replies View Related

Link Server Doesn't Work Except Through Query Analyzer: MSSQL Freezing / Timing Out

Jan 7, 2007

Environment:Server1 (Local)OS Windows 2000 ServerSQL Server 2000Server2 (Remote)OS Windows 2003 ServerSQL Server 2000(Both with most recent service packs)Using Enterprise Manager, we have set up the Link Server (LINK_A) inthe Local Server 1 to connect to Server 2.The SQL we need to run is the following:INSERT INTO table1(column1,column2)SELECT A.column1, A.column2FROM LINK_A.catalog_name.dbo.table2 AS AWHERE A.column1 xxxx;When we run this from the Query Analyzer, it completes with no problemsin a few seconds.Our problem:When we add the DTS Package as the ActiveX Script (VB Script) to theLocal Package, it times out at "obj_Conn.Execute str_Sql"Dim Sql, obj_ConnSet obj_Conn = CreateObject("ADODB.Connection")obj_Conn.Open XXXXobj_Conn.BeginTransstr_Sql = "INSERT INTO table1("str_Sql = str_Sql & "column1"str_Sql = str_Sql & ", column2"str_Sql = str_Sql & ")"str_Sql = str_Sql & " SELECT A.column1"str_Sql = str_Sql & ", A.column2"str_Sql = str_Sql & " FROM LINK_A.catalog_name.dbo.table2 AS A"str_Sql = str_Sql & " WHERE A.column1 0"str_Sql = str_Sql & ";"obj_Conn.Execute str_Sql----------------------------------------------------------When we make a Stored Procedure and run the following SQL, it freezes.INSERT INTO table1(column1,column2)SELECT A.column1, A.column2FROM LINK_A.catalog_name.dbo.table2 AS AWHERE A.column1 xxxxWe've also tried the following with the same results;INSERT INTO table1(column1,column2)SELECT A.column1, A.column2FROM [LINK_A].[catalog_name].[dbo].[table2] AS AWHERE A.column1 xxxxThe same thing happens when we try to run the "SELECT" by itself.SELECT TOP 1 @test=A.column1FROM LINK_A.catalog_name.dbo.table2 AS AWHERE A.column1 xxxxORDER BY A.column1What is going wrong here, and how do we need to change this so that itruns without timing out or freezing?

View 2 Replies View Related

SQL Query Timing Out

Jun 11, 2008

Hi
I have a query which executes in 1 second and returning 14 rows whenever I execute it through Management Studio but when I execute it from a web page I am getting a timeout message and the stack trace is pointing towards the line which calls the stored procedure. The query is quite complex and there quite a few joins on tables and views including one to a lookup table, whenever I take out join onto the look up table the web page runs ok without timing out. I join the Lookup table (Parts) using a Left Outer Join similar to below. The syntax of the Join is fine but I cant find why it would cause the query to time out when executed from a webpage but is fine when I execute it from Management Studio
 select *
from tables/view LEFT OUTER JOIN
Parts on Parts.PartNumber=tables/View.PartNumber
 I've tried recompiling the Parts table but it didnt make any difference.
 Any help would be much appreciated.
 Cheers,
Frankie

View 3 Replies View Related

Query Inexplicably Timing Out

Feb 29, 2008

I wrote a simple VB.NET utility program that uses a While...End While loop to go through all of the records in a table. Each time throgh that loop, an UPDATE command is assembled and assigned to the .CommandText property of an SqlCommand object. The command updates a record in another table by an ID field--based on the contents of the first table as well as the result of a lookup in another table. The update command is then executed each time within the loop via the .ExecuteNonQuery() method of the SqlCommand object. Again, it's important to point out that the update command updates only *one* record each time it is executed.

This program had been working fine until yesterday--when the query began timing out on the .ExecuteNonQuery() command. I have a counter within the loop and have been able to determine that the timeout occurs on the 3,359th time the query is called. The specific message is:


Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Re-running the program causes the same result at the same record.

I copied the query (whose ID updates the same 3,359th record) and executed it in SQL Server Management Studio; it timed out there, too. When I set the "Execution time-out" value to 0 (i.e., unlimited), the query ran for over an hour before I manually canceled it.

I can update all other tables in this database. I can also view (i.e., SELECT) the record that the update query is timing out on. I can also update any of the first 3,358 records in the SQLMS. However, the query continues to time out on the 3,359th record--and on any other record after that point.

The program was written on, and is running on, the SQL Server computer. The server has plenty of drive space. Both the database file and the log file for this database seem properly set to autogrow. I cycled the MSSQLSERVER service, but the query still times out at the same point. Rebooting the server did not resolve the problem, either. I don't see any errors in the Windows event logs.


What other methods can I use to try to resolve this problem?

View 9 Replies View Related

Timing Difference Between Query Analyzer And Profiler

Aug 1, 2014

We are trying to troubleshoot some website performance issues and found some queries taking 2 to 3 seconds when the request comes from the web, and captured by the Profiler.

The same queries, when run in the Query Analyzer take 0 seconds.

What could be the reasons for this difference, I mean why it takes 2 - 3 seconds shown by the Profiler, when it's 0 second in Analyzer?

View 3 Replies View Related

Full Text Timing Out Only On First Query Attempts

Oct 27, 2007

I'm running into a a problem with Full Text searching. I've narrowed my code that produces the error down to this:






Code Block

SELECT Content
FROM Text
JOIN CONTAINSTABLE(Text, Content, 'lake') AS A
ON A.[KEY]=Text.ID;


and here is how I initiated the full text for the table:






Code Block

sp_fulltext_database 'enable'
sp_fulltext_catalog 'theCatalogSearch','create'
sp_fulltext_table 'Text','create','theCatalogSearch','PK_Text'
sp_fulltext_column 'Text','Content','add'
sp_fulltext_table 'Text','activate'
sp_fulltext_table 'Text','start_full'
sp_fulltext_table Text, 'Start_change_tracking'
sp_fulltext_table Text, 'Start_background_updateindex'


The first time I run it in the SQL query analyzer it sits there for about 30 seconds and then gives me "Timeout expired (error - 2147217871)." After the first query attempt I can run it as many times as I want and it will work fine (no errors) ... But if I wait for about 30 minutes and then try it again, it will give the error again just on the first try. I've tried using search words that exist and ones that don't exist in the db and they both give the same error, so it's not that it's trying to return too many rows.

I'm using Microsoft SQL Server 2005. The code I'm writing is pretty basic so maybe it's the way that the database is set up or the way I initiated the full text tables? Any help would be greatly appreciated. Thank you.

View 3 Replies View Related

Full-text Serach Timing Out Only On First Query Attempts

Jan 25, 2008

I'm running into a problem with Full-Text searching. I have a procedure which uses a full-text search.
When I run it in SQL query analyzer €“ it runs immediately.
I exec this procedure from my ASP page and it returns timeout error.
After the first query attempt I can run it (executing the ASP-page) as many times as I want with different search words and it will work fine (no errors) ... But if I wait for about 30 minutes and then try it again, it will give the error again just on the first try.
I've tried using search words that exist and ones that don't exist in the db and they both give the same error, so it's not that it's trying to return too many rows.

I'm using Microsoft SQL Server 2005.
Any help would be greatly appreciated.
Thank you.

View 2 Replies View Related

Trigger With Access To Remote Server

Jan 6, 2007

Hello,

i have two server connected to internet S1 and S2 (connection between both is only internet too).

I need write trigger on S1 which send update or another command to S2. Is it possible, and how (without using .NET methods only by using Transact SQL)?

Thnx, jakub.

View 6 Replies View Related

SQL Server Timing Out

Mar 28, 2001

I use SQL Server to provide data to asp web pages and have recently started to get ODBC time outs throughout the day.

The environment is as follows:
Server with dual PII processors & 512MB RAM running:
- SQL Server 7
- IIS

I have a number of asp based web sites hosted on this box, but only 1 of them seems to be affected by the time out problem. I have checked the resources on the server (NT Task Mgr - Memoey & Processor) and everything seems fine - in fact the resources are hardly being touched!!!
Within a few minutes the problem disappears completely without me doing anything.

Am I missing something here?
Should I look elsewhere other than SQL - maybe IIS ???
Any suggestions / pointers would be very much appreciated.

Thx

View 1 Replies View Related

Append Query Problems

Nov 30, 2006

Hi

I am doing an A level database project. I need to build a system to deal with ordering and selling products.

I am trying to make an append query that will append all the products bought in my "invoices" table to my "archive" table. I want invoices that are three months old to be transferred the the "archive" table. I have been trying to put a criteria in the query for the Date field but I haven't managed to find an expression that works.

I'm sorry if this is too simple and you guys think im just being stupid.
I figured it was worth asking on here!! It's really bugging me.

View 6 Replies View Related

Append Query Problem

Jul 20, 2005

I'm testing this query and it does not append any new rows from thesource tables unless the destination table is empty. I want to designthe query just to add new records from the destination tables and leaveexisting ones in tact. Help appreciated. Query:INSERT INTO tMASmembers ( Division, CustomerNumber, CustomerName,AddressLine1, SalesPersonCode, SIC_Code, SIC_Desc )SELECT AR1_CustomerMaster.Division, AR1_CustomerMaster.CustomerNumber,AR1_CustomerMaster.CustomerName, AR1_CustomerMaster.AddressLine1,AR1_CustomerMaster.SalesPersonCode, AR_90_UDF_AR_Customer.Sic_Code,AR_90_UDF_AR_Customer.Sic_DescFROM AR1_CustomerMaster INNER JOIN AR_90_UDF_AR_Customer ON(AR1_CustomerMaster.Division = AR_90_UDF_AR_Customer.Division) AND(AR1_CustomerMaster.CustomerNumber =AR_90_UDF_AR_Customer.CustomerNumber)WHERE (((AR1_CustomerMaster.Division) Not In (Select[tMASmembers].[Division] From [tMASmembers])) AND((AR1_CustomerMaster.CustomerNumber) Not In (Select[tMASmembers].[CustomerNumber] From [tMASmembers])) AND((AR1_CustomerMaster.CustomerName) Not In (Select[tMASmembers].[CustomerName] From [tMASmembers])) AND((AR1_CustomerMaster.AddressLine1) Not In (Select[tMASmembers].[AddressLine1] From [tMASmembers])) AND((AR1_CustomerMaster.SalesPersonCode) Not In (Select[tMASmembers].[SalesPersonCode] From [tMASmembers])) AND((AR_90_UDF_AR_Customer.Sic_Code) Not In (Select[tMASmembers].[SIC_Code] From [tMASmembers])) AND((AR_90_UDF_AR_Customer.Sic_Desc) Not In (Select[tMASmembers].[SIC_Desc] From [tMASmembers])));*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 3 Replies View Related

SQL Server Timing Values?

Apr 21, 2008

I have a site that is experiencing the issue described in this doc. I'm unsure if the fix is going to blow anything up as I am unfamiliar with anything they are recommending.

http://support.microsoft.com/kb/931279



exec sp_configure 'affinity mask', 0x00000003
GO
reconfigure
GO


Any insight? Thanks,
Meg

View 2 Replies View Related

Single Query To Update And Append

May 5, 2004

I need to write a single query that will append the values from one table into another table but I need to update a single field in the table with a static value. What I'm working with is an Access .adp with an SQL 2000 backend. The database is used to track ticket sales, payments, and contact info for season ticket holders. Prior to upsizing, each year the database would be copied and then choice bits modified for the next year.

In other words, the history was in several databases, i.e. db2001, db2002, db2003 and for the current year dbcurrent. I decided to create a historic tables in the current DB rather than have umpteen DBs on my SQL server.

My problem is that I need to create a query that appends to my table the previous years data and then updates the season field to reflect the season that the data came from.

In short, say I have a table named accounts
with fields
account, customer, addr1, addr2, ..., ticket type
and I want it to end up in
account_hist with fields
account, customer, addr1, addr2, ..., ticket type, SEASON
and make the season equal say 8 which represents the 8th season the team has played.
I can get both queries to work seperately :D , but for end user ease, I want to perform both actions at the same time :confused: .
Can anybody point me in the right direction?
Thanks

View 2 Replies View Related

Append Query With Isnull Function

May 21, 2004

i'm trying to run an append query using data from 2 tables. i want to replace nulls with blanks ('') bellow is my statment. when i run this statment with out the iif(isnull)) statmentes the query works fine. is there another way of replacing my nulls with blanks.
Thank you,
Thomas

insert into tblcustomers (cusName, cusNumber, Active, cusContact, cusCrLimit,cusTerms)
SELECT dbo.tblCustomersIOA.CustomerName, dbo.tblCustomersIOA.Cust#,
dbo.tblCustomersIOA.Active,
iif(isnull(dbo.tblCustomersIOA.Contact),'',dbo.tbl CustomersIOA.Contact) ,
dbo.tblCustomersIOA.CreditLimit,
FROM dbo.tblCustomerNotesIOA RIGHT OUTER JOIN
dbo.tblCustomersIOA LEFT OUTER JOIN
WHERE (dbo.tblCustomersIOA.CountryID = 1) AND (dbo.tblCustomersIOA.StateID = 2);

View 1 Replies View Related

SQL Query - Append Data From Two Tables

Jul 20, 2005

I need to run a query which will pull data from two tables and appendit as one when it displays the result. The data are in two tables. Butthe result set will be identical in terms of number of columns. I wantto display it one set below the other.This is for pay history. From 2003 we have a new payroll system. Till2002 we used to have a different system. But I need to run a querywhich will pull the data for an employee for the last one year. So theinformation is spread out between these two tables. Both these tablesare in SQL Server databases.I want to write a Stored Procedure. I can use Shape/Append but I thinkit doesnt work on QA/Stored Proc. It needs an OLEDB.How can I write the query. I dont want to use temporary tables and doinserts.ThanksGIRISH

View 1 Replies View Related

Backup Restoration / Append Query

Jul 20, 2005

Hi All:Being a bit of a nube to MSSQL I could use a little advice. This is thesituation.A client's HDD became full so I backed up, deleted then recreated a blankdatabase (they said they didn't need the stored data).They have now deceided that they want the data again.My plan is to restore the database to a second volume so it can grow as muchas is needed, however, there is now data in the second instance that wouldneed importing to the restored DB.I can restore the backed up db with a different name and reconfigure thesoftware that accesses it but what would be the best method to append therestored DB with the data in the current instance of said DB? Both DBs areidentical.TIAMP

View 1 Replies View Related

How Do I Append String To End Of Sql Query Results?

Jul 20, 2005

I need to append text to the end of my sql query results.For instance, my query returns a list of user names infirstname.lastname. I need to add @yahoo.com to each record. So theend result should be Join Bytes!. What should byselect statement look like?Any help?

View 2 Replies View Related

Firing An Append Query(stored Procedure) On The First Of Very Month

Mar 4, 2002

I need several stored procedures to fire on the 1st of every month. I was told my another developer I can possibly use SQL sever agent.

Any ideas????

View 1 Replies View Related

Can I Access MS Access Table In A Select Query Of SQL Server

Nov 29, 2006

Is there a way to specify a MS Access table (or query object) in the select query of SQL Server.

Ex.:

MSAccessTable (in file.mdb)



col1
col2

a1
a2

b1
b2

SQL query in SQL Server:

SELECT col1, col2 into SqlTable from [file.mdb].MSAccessTable;

Thanks,

View 3 Replies View Related

Timing Is Everything? SQL Server Is Not Ready To Accept New Client Connections

Apr 18, 2007

I cannot understand how this was allowed to happen, but I can recreate the situation all day long. Someone, please tell me that I have missed an obvious solution to this;



With a fresh install of SQL 2005 Express (SP2) I have 4 databases installed and two service-based applications running. One of the service applications uses/requires three of the four databases and the second service application uses/requires the fourth database.



On boot, with the above described services set to depend on SQL Server service startup I get repeated failures on initial database access. Looking at the event log reveals why (in sequence):



SQL Server Startup...



Event: Server local connection provider is ready to accept connection on...

Event: Server named pipe provider is ready to accept connection on...

Event: Server is listening on [ 'any' <ipv4> 1911]



Application Service Startup...



Event: SQL Server is not ready to accept new client connections. Wait a few minutes before trying again. If you have access to the error log, look for the informational message that indicates that SQL Server is ready before trying to connect again



Moments Later:



Event: SQL Server is now ready for client connections. This is an informational message; no user action is required.





Now, its clear that the SQL service has started, and that this opens the floodgates for dependant services to start, each of which is told - essentially - to go away and come back once the SQL server has **really** started. With the accompanying suggestion to 'look for the informational message that indicates that SQL Server is ready' in the event log.



Am I reading the situation right so far?



In response to this, with my developer way of thinking, I could probably script the startup of application services rather than have them start automatically at boot or some such insane idea. But its not really the way that I had planned to spend the next few hours of my life, and it seems to me that I should not have to do such a thing.



Our in house service application (one of the two described) is in fact robust enough (just enough) to survive and to try the connection periodically, accomplishing a successful startup even with no database available.



The second of the two services is external and is unfortunately unable to start with no database available (Business Objects XI CMS). The normal means of making this service robust against database outages is the service restart procedure setting. But since the service doesnt ever start successfully, this doesnt work (learn something new every day - the restart is literal. It does not provide an initial startup retry and the service must have been started and fail for the retry to kick in)



Now, im not trying to bash anyone over this situation and regardless of the inflexible nature of the external service application and the general sillyness of the SQL server startup sequence - i mean c'mon... we are started but not ready? How about dont report startup until after you are ready? - the end result is that I need to come up with a solution to this problem.



I cant imagine that this is the first time that this behaviour has been questioned and I have to believe that there will be a simple, reliable workaround. I will keep looking for myself, but if any of this sounds familiar and you have a suggestion, your response will be greatly appreciated.



View 2 Replies View Related

Sql Server 2005 Queries Start Timing Out Because Sa Is Acquriing And Releasing Locks

Oct 23, 2007

I have a co-worker whose sql server 2005 is exhibiting strange behavior. We have already re-installed sql server 2005 and service packed it to SP2 to try and see if the behavior stops but it has not.

Every so often during the day sql server 2005 will start to slow down to the point that my co-worker's queries begin to time out. He turned on profiler to look at what was going on behind the scenes.

We see where sa is releasing and acquring locks to the tune of 180,000 rows in a fifteen minute span when this behavior starts so does his time outs. He has reporting options and analysis services installed but not configured. His only connection is to his local database. Occasionally, you see a number like - (03000d8f0ecc) appear in the Text Data column in profiler for sa. I read something about reporting options using sa for clean up but I don't think that is what is happening here.

Does someone have a clue as to what is happening and a way we can prevent the behavior? It is affecting his ability to work on his application.

Thx

View 1 Replies View Related

SQL Server 2014 :: Stored Proc Timing Out Halfway Through - Rolling Back Without Transaction

Jul 7, 2015

We have a high volume database with 1000's of users and 1000's of procs. Our application enforces a 20 second timeout on all connections.

We can't adjust the 20 seconds - this is a business rule.

It sometimes happens that a proc does not complete within 20 seconds and then times out halfway though. This causes data inconsistency where 50% of the code was saved to the DB and 50% was not - seeing that a stored proc is not transactional and therefor does not roll back the code.

We can't put the code in a TRANSACTION in order to roll back when a time out occurs, because this causes exclusive locks on the tables.

So I guess my question is:
Is it possible to undo/rollback all the code in a proc when a timeout occurs - without using a TRANSACTION? And if a TRANSACTION is the only way - how do I avoid the exclusive lock and blocks?

View 4 Replies View Related

SQL Server Trigger Query

Aug 24, 2007

I have a trigger written below to update another table when one table is updated.
Basically it works when i update row after row from enterprise manager However when i use a script to update 10 or 20 rows then this trigger does not work. Can any one offer any suggestions on where this issue could be ?


DECLARE @iCount INT
DECLARE @OldValue VARCHAR(255)
DECLARE @NEWVALUE VARCHAR(255)
DECLARE @EQNAME VARCHAR(255)
DECLARE @EQTYPE VARCHAR(255)
DECLARE @TEST VARCHAR(255)
SET @NEWVALUE = 'INIT'
IF (UPDATE(VALUE))
BEGIN
SELECT @OldValue = deleted.value from deleted
SELECT @NEWVALUE = inserted.VALUE,@EQNAME = inserted.EQ_NAME FROM inserted where inserted.attr = 'AreaCfg'
IF (@@ROWCOUNT =0)
BEGIN
RETURN
END
IF ((@NEWVALUE = '') OR (@NEWVALUE is NULL))
BEGIN
DELETE [TABLE-1] WHERE ENTITYID = @EQNAME
RETURN
END
IF ((@NEWVALUE != @OldValue))
BEGIN
SELECT @iCount = Count(*) FROM [TABLE-1] WHERE ENTITYID = @EQNAME
IF (@iCount = 0)
BEGIN
-- No records are available so insert
SELECT @EQTYPE = Typ FROM IP_EQ WHERE EQ_NAME = @EQNAME
INSERT INTO [TABLE-1] (AlarmGroupId, EntityID, EntityType, OwnerId) VALUES (@NEWVALUE,@EQNAME,@EQTYPE,'Production Tracker')
END
IF (@iCount > 0)
BEGIN
-- No records are available so insert
SELECT @EQTYPE = Typ FROM IP_EQ WHERE EQ_NAME = @EQNAME
UPDATE [TABLE-1] SET ALARMGROUPID = @NEWVALUE WHERE ENTITYID = @EQNAME
END
END
END

View 3 Replies View Related

Running Query In Linked Server Through Trigger

Aug 2, 2006

i have set up
a linked server. i can query the linked server in query analyzer and
also do update/delete. but when i try to run the same query for linked
server through insert trigger, i get following error: [OLE/DB provider returned message. [Microsoft][ODBC Sql Server Driver]Distributed transaction error].btw, i am using Sql server 2000, SP4. main server is windows 2003 server and linked server is windows xp pro.any suggestions will be appreciated.

View 1 Replies View Related

SQL Server 2005 Query/trigger/function (whatever It Is That I Need)

Dec 8, 2006

Hey guys maybe you can help me out, been trying to figure this one out all day at work. I know how to use columns in a table to calculate another column in that same table. But I need to do some math on columns from a totally seperate table. Here is my scenario
 table 1 = stock table
 table 2 = Purchase order table
 in table 2 there are line items that have ordered quantities for parts that we have ordered
 in table 1 under each part number is a field for "quantity on order"
I need to compute the "quantity on order" in table 1 by summing all of the quantities in table 2 where the partnumber = the partnumber from table 1
 
quantity on order (table 1) = sum of all quantities (table 2) where the part numbers match
so for part number 516 i have this
 
table 2
poNumber             partNumber                 quantity
1                             516                             1
2                             516                             12
3                             516                             4
 
table 1
partNumber            inStock              onOrder
516                          0                        17(this is what i am trying to figure out how to compute)
 
any help on this qould be appreciated. I would like the database to automatically do this itself if at all possible.

View 3 Replies View Related

MS Access Query That I Would Like To Convert To MS SQL Server Query

Jun 28, 2005

I have the following query created in MS Access that I would like to convert to MS SQL Server, but I can't get the IF logic to work properly, any help you can provide would be greatly appreciated.


Code:

SELECT Customer.Last_Name, Customer.First_Name, Customer.Middle_Name, Customer.Address, Customer.City, Customer.Region, Customer.Postal_Code, Customer.Country, Orders.Order_ID, Customer.Customer_ID, Employees.LastName, Employees.FirstName, Order_Line.Item_ID, Item.[Long Description], Order_Line.Units_Purchased, Order_Line.Price, Order_Line.Discount, CCur(Order_Line.Price*[Units_Purchased]*(1-[Discount])/100)*100 AS ExtendedPrice, Store.Store_Address, Store.Store_City, Store.Store_State, Store.Store_Zip_code, Store.Store_Phone_Number, Store.Store_Fax_Number, Item.Taxable_Nontaxable,
IIf(Item.Taxable_Nontaxable=Yes,([ExtendedPrice]*Tax_Table.Tax_Rate),([ExtendedPrice]*0)) AS Tax_Amt,
Tax_Table.Tax_Rate

View 3 Replies View Related

SQL Server 2014 :: How To Append Rows Horizontally

Nov 4, 2015

I'm trying to append rows horizontally - I'm using the "xml path" approach

SELECT
E.[USER_NAME] As 'User Name',
(
SELECT ',' + C.[PERMISSION_NAME]
FOR XML PATH('')
) As [Associated Groups]
FROM TABLEA As A
JOIN TABLEB AS B ON A.PK_OBJ_ID = B.FK_APP_OBJECT_REF
JOIN TABLEC AS C ON C.PK_PERMISSION_ID = B.FK_PERMISSION_REF
JOIN TABLED AS D ON D.FK_PERMISSION_REF = C.PK_PERMISSION_ID
JOIN TABLEE AS E ON E.PK_PERSONNEL_ID = D.FK_PERSONNEL_REF
WHERE A.[OBJECT_NAME] = 'MyObjectName'

It's not working. I'm getting:

User nameAssociated Groups
A. SmithG1
A. SmithG2
A. SmithG3
etc...

What I'm looking for is:

User NameAssociated Groups
A. SmithG1, G2, G3
etc...

View 3 Replies View Related

Append Query To Insert 80000 From One Table To Empty Table

Jul 22, 2012

All, Using access 2003 frontend and sql server 2008 backend. I have an append query to insert 80000 from one table to an empty table. I get an error:

"Microsoft Office Access set 0 field(s) to Null due to a type conversion failure, and didn't add 36000 record(s) to the table due to key violations, 0 record(s) due to lock violations, and 0 record(s) due to validation rule violations."

I know this error normally comes if there are dups in a field that doesnt allow.

View 1 Replies View Related

SQL Server 2012 :: How To Append Underscores Based On The Level

Oct 8, 2014

I have a table that looks like below.

DECLARE @Tree TABLE
(
NAME VARCHAR(100),
[LEVEL] INT
)
INSERT INTO @Tree
SELECT 'ABCD', 1
UNION
SELECT 'ABBBCDD', 2
UNION
SELECT 'AABBCCDD', 2
UNION
SELECT 'AAAABBBBCCCCDDDD', 3

My question is based on the Level, I want to append that many _(underscores) before the name.

Eg : for level 3 I want the name as ___AAAABBBBCCCCDDDD.

I was thinking to insert this into a temp table and call a while statement based on the number.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved