I am using the update query listed below in my DetailsView. The issue i am having is the ManagerDecision value which gets populated in a DropDownList in EditTemplate, doesnt seem to update correctly. If I choose 'Approved' from the DropDownList, the result for Status_Type ends up being 'Closed' and not 'Open'. Could someone please Help.
Thanks!!
UPDATE ServiceRequest_Table
SET ManagerDecision = @ManagerDecision, Comments = @Comments, Priority_Name = @Priority_Name, Status_Type =
CASE WHEN (ManagerDecision = 'Approved') THEN 'Open'
ELSE 'Closed' END,
ManagerDateTime = CASE WHEN (Status_Type = 'Closed') THEN '' END,
Closed_Date = CASE WHEN (Status_Type = 'Open') THEN '' END WHERE (ServiceRequest_ID = @ServiceRequest_ID)
Hi! Select gets all records that contains illegal chars... Ok, to replace '[' { and some other chars I will make AND '% .. %' and place other intervals, that is not the problem.The problem is: How to replace not allowed chars ( ! @ # $ % ^ & * ( ) etc. ) with '_' ?I have seen that there is a function REPLACE, but can't figure out how to use it. 1 SELECT user_username 2 FROM users 3 WHERE user_username LIKE '%[!-)]%';
I'm looking for a query that can "batch" update one table from another. For example, say there are fields on both tables like this: KeyField Value1 Value2 Value3 The two tables will match on "KeyField". I would like to write one SQL query that will update the "Value" fields in Table1 with the data from Table2 when there is a match.
Hi there,I'm a little stuck and would like some helpI need to create an update trigger which will run an update query onanother table.However, What I need to do is update the other table with the changedrecord value from the table which has the trigger.Can someone please show me how this is done please??I can write both queries, but am unsure as to how to get the value ofthe changed record for use in my trigger???Please helpM3ckon*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
Can I roll back certain query(insert/update) execution in one page if query (insert/update) in other page execution fails in asp.net.( I am using sqlserver 2000 as back end) scenario In a webpage1, I have insert query into master table and Page2 I have insert query to store data in sub table. I need to rollback the insert command execution for sub table ,if insert command to master table in web page1 is failed. (Query in webpage2 executes first, then only the query in webpage1) Can I use System. Transaction to solve this? Thanks in advance
Hello, I have the following query in Access 2000 that I need to convertto SQL 2000:UPDATE tblShoes, tblBoxesSET tblShoes.Laces1 = NullWHERE (((tblShoes.ShoesID)=Int([tblBoxes].[ShoesID])) AND((tblBoxes.Code8)="A" Or (tblBoxes.Code8)="B"))WITH OWNERACCESS OPTION;The ShoesID in the tblShoes table is an autonumber, however the recordsin the tblBoxes have the ShoesID converted to text.This query runs ok in Access, but when I try to run it in the SQLServer 2000 Query Analizer I get errors because of the comma in the"UPDATE tblShoes, tblBoxes" part. I only need to update the tblShoesfield named Laces1 to NULL for every record matching the ones in thetblBoxes that are marked with an "A" or an "B" in the tblBoxes.Code8field.Any help would be greatly appreciated.JR
I have an update query running which to just now has been running for 22 hours running on two tables 1 a lookuptable that has just been created within the batch the other a denormalised table for doing data analysis on
the query thats causing teh problem is
--//////////////////////////////////// this is the one thats running
Print 'Update Provider 04-05 EmAdmsCount12mths : ' + CAST(GETDATE() AS varchar) GO Update Provider_APC_2004_05 set EmAdmsCount12mths = (Select COUNT(*)-1 from Combined_Admissions where ((Combined_Admissions.NHSNumber = Provider_APC_2004_05.NHSNumber) or (Combined_Admissions.PASNUMBER = Provider_APC_2004_05.PDDISTNO)) and (Combined_Admissions.AdmDate BETWEEN DateAdd(yyyy,-1,Provider_APC_2004_05.AdmDate) AND Provider_APC_2004_05.AdmDate) AND Combined_Admissions.AdmMethod like 'Emergency%')-- and -- CA.NHSorPrivate = 'NHS')) FROM Provider_APC_2004_05, Combined_Admissions
any help in improving speed would be most welcome as there are 3 more of these updates to run right after this one and the analysis tables are almost double the size of this one
This is my first website done in ASP.NET and SQL Server 2005. I haven't ran into any major problems, until I tried to run an update on some rows. I've searched everywhere online, only to be stuck at the end of the day. I will post the code I have for the button that triggers it. I'll be crossing my fingers! int eid = Int32.Parse(Request.QueryString["id"]); string updateSQL = "UPDATE Events SET event_title = @event_title, event_date = @event_date, "; updateSQL += "event_time = @event_time, event_location = @event_location, event_description = @event_description WHERE (eid = @eid)";
SqlConnection con = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(updateSQL, con); cmd.CommandType = CommandType.Text;
Hi everyone!I have a update query which all looks good and it looks like it executes, though it does not effect the database for some unknown reason. (No error messages).protected void Button1_Click(object sender, EventArgs e) { int areaId = 0;
if (Request.QueryString["doc_area_id"] != null) { areaId = Convert.ToInt32(Request.QueryString["doc_area_id"]); }
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["CPS_docshareConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("UPDATE document_area SET doc_area_name = '" + AreaText.Text + "' WHERE doc_area_id = @areaId", myConnection);
OK, so I have this page where a user can edit multiple fields in a database record. My problem is, that once changes have been made and the user hits the "save" button, everything SEEMS to run just fine (no errors, other things that should happen when the button is clicked happen normally), but nothing is changed. It's almost like the update function (which was created with Microsoft ASP.NET Web Matrix) is working, but it's being fed the old values for the page, rather than the updated ones. Any ideas on what might be causing this? It's not like anything I've seen before. Thanks Kaiti
I gave a storedprocedure for gatting data into gridview,just go through that. Select Ind.Industry_Name,Com.Company_Address from Pcra_Industry Ind join Pcra_Company Com on Ind.Ind_ID_PK=Com.Ind_ID_FK Here iam getting two fields from two different table depending on the Id. So how to write a Query to change the fields in the different tables. please Help me...
Im having a problem when using my update statement on button click. I want the field to be updated to be true whenever the button was clicked but it doesn't seem to like my current syntax. Can someone point me in the right direction please? I know its really simple but when you have just been looking at something for so long you can never see it!!! Thanks SqlCommand myCommand = new SqlCommand("Update Notice SET Resolute = '" + Resolute + "', DateClosed= '" + DateClosed + "', Resolved = 'True' WHERE NoticeID = " + NoticeID + "", myConnection);
Hi Guys I have a problem with UPDATE query. Here is my Select query. SELECT d.EID as EID,d.EName as EName,d.EDOB as EDOB,d.EDesignation as EDesignation,d.ESal as ESal,EI .EPhone as EPhone,EI .EEnddate as EndDate FROM Data_EMP d Join Emp_Info EI on d.EID=EI.EIDWhere d.EID ='1001' According to this query I have to update another query.This is my original Update Query. "Update Data_EMP set EStatus=0 where EID='" & TempEID & "'" Now i wrote update query like this UPDATE d.EID as EID,d.EName as EName,d.EDOB as EDOB,d.EDesignation as EDesignation,d.ESal as ESal,EI .EPhone as EPhone,EI .EEnddate as EndDate FROM Data_EMP d Join Emp_Info EI on d.EID=EI.EIDSet set EStatus=0 where EID='" & TempEID & "'" Shall i write Update query like this and Is there any issues in this update query can any one let me know? Thanks
I am going to create a mastercustomerid column whose value will be the min(customerid) in the above scenario. I need a query where I can achieve this
I used the query below to achieve the above results
SELECT a.customerid, lastname, firstname, emailaddress FROM account.Customer a Join account.Email b ON a.customerid = b.customerid WHERE lastname in ( SELECT lastname FROM account.Customer c Join account.Email d ON c.customerid = d.customerid GROUP BY lastname, firstname, emailaddress HAVING count(*) >1 AND firstname = a.firstname AND emailaddress = b.emailaddress ) ORDER BY lastname, firstname, emailaddress
I need to update 349862 rows with a mastercustomerid . Please help me.
I have an update query which updates a field if the contents of 3 other fields in the table matches the result of a Where clause. Is it possible to only update the first matched row in the table rather than all rows that match the Where clause. Forgive if this is simple but I am a newbie to SQL 7. Regards Andrew Wall
I have the following table: AreaName Population RankNumber ======== ========== ========== Annerley 200 NULL Balmoral 50 NULL Chermside 350 NULL
Is it possible the write an update query that, after ordering the table by Population, it sets RankNumber to 1 for the first row, sets RankNumber to 2 for the second row, and so on??
The resultant table would look like: AreaName Population RankNumber ======== ========== ========== Balmoral 50 1 Annerley 200 2 Chermside 350 3
I want to update the code so that all records with the same category has the same code. It would also start with 1. The end result would be the following:
CATEGORY ACCT CODE
C ABC 1 C XYZ 1 A EFG 2 A PQR 2 A LMN 2 B STU 3 D IJK 4
Maybe some one can help me... I have 2 tables with the following structure: CREATE TABLE [table1]( [GRID] [int] IDENTITY (1, 1) NOT NULL , [GID] [varchar] (10) NOT NULL , [RID] [int] NOT NULL ) On primary
CREATE TABLE [table2] ( [RID] [int] IDENTITY (1, 1) NOT NULL , [RText] [varchar] (400) NULL ) ON [PRIMARY]
If [RID] in table 1 exists more then one time (the first occurence leave as is) and then create a new [RID] every time it is found in table2 with the RText from [RID] and update table1 with applicable [RID] .
I have a query i need to write that will effect over 12,000 rows of data so i can't get it wrong! Can anyone give me some advice i can update individual records using ASP and uniqueid's but this query need to be done on SQL Exp browser.
What i have is 2 columns one called fxactivitystatus and one called activitystatus i need to copy all the fxactivitystatus fields to the activitystatus fields where the activitystatus are blank.
HI Guys Wonderful to see you again and of course I have a question for ya.. I have a query that finds matching records in two tables one is the Conditional Table the other is the Termination table. What I would like to do is update the records it finds, which is basically a yes/no field. It bascially says if a terminated employee was once on a conditional they the field will say yes. and I need to update that field to yes. This query produces approximately 150 records that the Termination.tbl and the ConditionalLicense_View have in common and I need to change those 150 records Yes/No to a Yes?? does that make sense??
SELECT ConditionalLicense_View.[TM #], ConditionalLicense_View.FirstName, ConditionalLicense_View.LastName FROM ConditionalLicense_View LEFT JOIN TERMINATION ON ConditionalLicense_View.[SS#] = TERMINATION.SocialSecurityNumber WHERE (((TERMINATION.SocialSecurityNumber) Is not Null));
table2 is the latest table with updates, some of the fields in the extension field are nulls. i want to update table1.extension to table2.phonenumber based on the primary key directoryid
update table1 set table1.extension = table2.phonenumber INNER JOIN table2 on table1.directoryid = table2.directoryid where table1.extension = '' or table1.extension is NULL.
I run the query below and get the error message below the query. How can i do this update?
UPDATE GEO_Plaats SET NetNummer = (SELECT GEO_Netnummers.Netnummer FROM GEO_Netnummers WHERE GEO_Netnummers.Plaats = GEO_Plaats.Plaats) WHERE EXISTS (SELECT GEO_Netnummers.Netnummer FROM GEO_Netnummers WHERE GEO_Netnummers.Plaats = GEO_Plaats.Plaats);
ERROR:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated.
I want to create a query where the system calculates the bonus for each transaction by looking up the SALES_STOCK_BONUS table to see if there is a valid bonus for the product in that transaction (when transaction falls between dateTo and dateFrom of a bonus)
(productHeadings is a link table between the SALES_STOCK table and SALES_STOCK_BONUS)
eg if heading.id = 25 and had a bonus of 13 between 01/01/04 and 01/04/05 and then had bonus 15 between 02/04/05 - 01/10/06 ...but this query assigns the same bonus(13) for all transactions with product heading.id = 25 whateva the date....
UPDATE SALES SET SALES.Bonus = SALES.Sale *(SALES_STOCK_BONUS.Bonus/100) FROM SALES, SALES_STOCK, SALES_STOCK_BONUS, productHeadings WHERE SALES.Product = SALES_STOCK.Product AND SALES.Whse = SALES_STOCK.Whse and productHeadings.heading_name = SALES_STOCK.heading2 and SALES_STOCK_BONUS.id = productHeadings.id and (CONVERT(CHAR(10),SALES.[Date],110)>= CONVERT(CHAR(10),DateFrom,110) and CONVERT(CHAR(10),SALES.[Date],110) <= CONVERT(CHAR(10),DateTo,110)) and SALES_STOCK_BONUS.Bonus is not null
It doesnt seem to check the date for each one individually.... PLS help!!!
The query below executes successfully but it updates all the records. I want to update only the parameters on the 'where' clause. What am I missing?
Thanks.
UPDATE tblIncident SET UnprocessedPoints = 6 FROM [tblIncident] as Incident, [tblperformedaudit] as Audit where ((incident.databaseid = audit.databaseid) and (audit.auditnbr = 2) AND (audit.doctype = 'CLAIM')OR(audit.doctype = 'TAR') OR (audit.doctype = 'CIF') AND (audit.monthofsample = 'oct') And (Incident.Status <> 'Removed' ) AND (Incident.typeofFindings = 'Error') AND (Incident.errorID = 'Unprocessed'))
hello, This is the update query that I have created. Let's say @UnderlyingIndexID is to be set to null instead of an existing value of 10. I think this query does not allow for such an update. How can this query be altered to do so? Thanks
I have two tables, returnparts and dataimport. I am trying to update the ReviewNumber in the dataimport table with the reviewnumber in the returnparts table. Here is my query...
UPDATE DataImport SET dataimport.ReviewNumber = returnparts.ReviewNumber From returnparts r, dataimport d where d.Customer = r.Customer and d.[Review Date] = r.ReviewDate and d.[Ref #] = r.referencenumber and d.disposition = r.Disposition and d.[Vehicle ID Number] = r.VIN and d.[Model Year] = r.ModelYear and d.[repair order #] = r.repairordernumber and d.[repair date] = r.repairorderdate and d.engine = r.engine and d.model = r.model and d.mileage = r.mileage and d.[customer comments] = r.customercomments
Here is the error message I receive when I run this query.
Server: Msg 107, Level 16, State 3, Line 1 The column prefix 'returnparts' does not match with a table name or alias name used in the query.
I thought I had the syntax correct but apparently I don't. Any help would be appreciated.
I have 2 tables A and B. Due_Date in table B has to be updated by the max(Due_Date) from table A only if a record entry for the same ID is present in Table A, otherwise the date remains the same.
IDDue_Date 12001-01-01(gets updated from table A) 22001-02-01(gets updated from Table A) 32004-01-01(gets updated from Table A) 42001-01-01(since no record in table A, date remains the same) 52004-03-03(gets updated from Table A) 62001-01-01(since no record in table A, date remains the same)
I need to write a stored procedure for this, input to this stored procedure will be the 'ID'. Please help me out.
I am trying to update a field based on two conditions.
UPDATE VoicewareSQL1.dbo.Dictations SET state = 22 Where doctorID = 920 and state = 18
I get the following error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
I tried making the conditons a subquery, but could not get that to work either.