Update Rows With Next Higher Id, If It Exists

Jul 20, 2005

I am trying to determine the next registered session of a student so I
can calculate the number of skipped sessions.

Scenario: I have a student registration summary table. One row for
each student and the student's registered session. I want to update a
given row with the next higher registered session (into a field called
next_registered_session_skey if the row exists). I can then use the
diff of the skeys to determine how many sessions the student skipped
for each registration period.

Example: Student X registers each fall for one session for 4 years.
The file might look like:

STUDENT_ID SESSION_ID SESSION_SKEY
NEXT_REGISTRED_SESSION_SKEY
123456789 200201 100
null
123456789 200301 104
null
123456789 200401 108
null
123456789 200501 112
null

I need to update the NEXT_REGISTRED_SESSION_SKEY so I end up with:
STUDENT_ID SESSION_ID SESSION_SKEY
NEXT_REGISTRED_SESSION_SKEY
123456789 200201 100
104
123456789 200301 104
108
123456789 200401 108
112
123456789 200501 112
null

I can then say SESSIONS_SKIPPED = NEXT_REGISTRED_SESSION_SKEY –
SESSION_KEY (logically speaking, not syntactically)

This is what I have so far as example:
UPDATE F_REGISTRATION
SET NEXT_REGISTERED_SESSION_SKEY = (
select top 1 nextr.session_skey
from f_registration r
inner join
f_registration nextr
on r.student_skey = nextr.student_skey and nextr.session_skey[color=blue]
> r.session_skey[/color]
order by r.session_skey desc
)
WHERE STUDENT_ID = '577665705';

SELECT student_skey, student_id, session_id, session_skey,
next_registered_session_skey, * FROM F_REGISTRATION WHERE STUDENT_ID
= '577665705' order by session_skey desc

RESULTS:

STUDENT_SKEY STUDENT_ID SESSION_ID SESSION_SKEY
NEXT_REGISTERED_SESSION_SKEY
125137 577665705 200404 309 311
125137 577665705 200403 308 311
125137 577665705 200402 307 311
125137 577665705 199804 285 311
125137 577665705 199803 284 311
125137 577665705 199802 283 311
125137 577665705 199704 281 311

TIA

Rob

(I restricted with the where = ‘577665705' so I did not have to wait
to update all the rows)

View 6 Replies


ADVERTISEMENT

SQL Server 2012 :: Update Statement Will Not Update Data Beyond 7 Million Plus Rows Out Of 38 Millions Rows

Dec 12, 2014

I run the following statement and it will not update beyond 7 million plus rows and I have about 38 million to complete. I keep checking updated row counts and after 1/2 day it's still the same so I know something is wrong because it was rolling through no problem when I initiated it. I need to complete ASAP so it's adding to my frustration. The 'Acct_Num_CH' field is an encrypted field (fyi).

SET rowcount 10000
UPDATE [dbo].[CC_Info_T]
SET [Acct_Num_CH] = 'ayIWt6C8sgimC6t61EJ9d8BB3+bfIZ8v'
WHERE [Acct_Num_CH] IS NOT NULL
WHILE @@ROWCOUNT > 0
BEGIN
SET rowcount 10000
UPDATE [dbo].[CC_Info_T]
SET [Acct_Num_CH] = 'ayIWt6C8sgimC6t61EJ9d8BB3+bfIZ8v'
WHERE [Acct_Num_CH] IS NOT NULL
END
SET rowcount 0

View 5 Replies View Related

How To Update With SQL EXISTS(?)

Jul 20, 2005

Hi,I have 2 tables in an SQLServer db.I want to compare table A with table B and add any records that EXISTin table B but dont exist in table A, to table A.Can anyone help me with the SQL?TIAHitcher

View 1 Replies View Related

Return Rows Only If More Than 1 Row Of The Same Policy Number Exists?

Sep 25, 2007

I have a policy table which has policyNumbers and createDate. I need to retrieve all rows where createDate is between 2 dates and there is more than 1 row with the same policy number. I cannot figure out the SQL to return all policy number rows if there are more than 1 row with the policy. Most policies number will be in the table once. I need the others.

Thanks for suggestions.

View 1 Replies View Related

Insert If Not Exists Else Update

Apr 4, 2007

Hello,

it's me again :)
I've got a - what I think - simple question.
There is table A with Col1,Col2,Col3 and Table B with Col1,Col2,Col3

I want all rows from B in A. If a row already exist in A, then update all columns, else just insert the row.
Can someone please help me with a small syntax.
Thank you!

View 6 Replies View Related

Checking To See If A Records Exists Before Inserting - 3 Million + Rows

Aug 21, 2007

I have 1+ CSV files (using a foreach loop) which I'm doing a lot of transform work on and then inserting into a SQL database table.
Each CSV file usually contains about 2 days worth of data (contains date stamps) - somewhere in the region of 60k records per day.
The destination table currently contains 3 million+ rows and will get bigger.
I need to make sure that before inserting into the destination table, the data doesn't already exist.

I've read the following article: http://www.sqlis.com/311.aspx
While the lookup method works, it takes ages and eats up memory as it caches the 3m+ records before running for each CSV. Obviously this will only get worse as the table grows in size.

To make things a little more efficient what I'd like to do, is first derive the dates I'm dealing with in the current file - essentially storing the max(date) and min(date) in variables. Then in the lookup SQL use those vars, to reduce the amount of data that needs to be brought into the transformation to check against before inserting into the destination table.
Lookup SQL eg. SELECT * FROM MyTable WHERE Date BETWEEN varMinDate AND varMaxDate.

Ideally I'd use an aggregate transformation and then use the subsequent output from that either in the lookup query or store the output in vars, but I don't think you can do that and I get the feeling I'm approaching this with the wrong mindset.

Any thoughts would be great!

View 6 Replies View Related

IF Exists UPDATE ELSE INSERT Problem

Feb 18, 2004

Hi,

I have a 'Products' table (with: 'uid' and 'CatName' columns) and 'ProductCategory' table (with: 'uid', 'ProductID', 'CategoryID' columns).

I got stored procedure below to update or insert new row to 'ProductCategory' table whenever 'Products' table has been updated or new products has been added to it.

Update part works just fine but when new row has been added to 'Products' this storedProc dosn't insert it into 'ProductCategory' table, it does that only when 'ProductCategory' table is empty, I'm afraid it's because first column 'uid' in 'ProductCategory' table is an Identity column... I’m not sure how should I go about that problem. This is my stored procedure:

DECLARE @CatNo INT, @CatName varchar(10)
SET @CatNo = 2
SET @CatName = 'bracket'

IF exists (SELECT ProductID from ProductCategory, Products where ProductCategory.ProductID = Products.uid and Products.CatName = @CatName )
BEGIN
UPDATE ProductCategory SET CategoryID = @CatNo
FROM Products WHERE Products.CatName = @CatName and ProductCategory.ProductID = Products.uid
END
ELSE
BEGIN
INSERT INTO ProductCategory ( ProductID, CategoryID)
SELECT uid, @CatNo FROM Products
WHERE Products.CatName = @CatName
END

SET @CatNo = 3
SET @CatName = 'cable'

IF exists (SELECT ProductID from ProductCategory, Products where ProductCategory.ProductID = Products.uid and Products.CatName = @CatName )
BEGIN
UPDATE ProductCategory SET CategoryID = @CatNo
FROM Products WHERE Products.CatName = @CatName and ProductCategory.ProductID = Products.uid
END
ELSE
BEGIN
INSERT INTO ProductCategory ( ProductID, CategoryID)
SELECT uid, @CatNo FROM Products
WHERE Products.CatName = @CatName
END
(... Goes for another 37 categories)



Thank you for help.

Kooba

View 3 Replies View Related

How To Update If Exists Else Insert In One SQL Statement

Jul 20, 2005

In MS Access I can do in one SQL statement a update if exists else ainsert.Assuming my source staging table is called - SOURCE and my targettable is called - DEST and both of them have the same structure asfollowsKeycolumns==========MaterialCustomerYearNonKeyColumns=============SalesIn Access I can do a update if the record exists else do a insert inone update SQL statement as follows:UPDATE DEST SET DEST.SALES = SOURCE.SALESfrom DEST RIGHT OUTER JOIN SOURCEON (DEST.MATERIAL = SOURCE.MATERIAL ANDDEST.CUSTOMER = SOURCE.CUSTOMER ANDDEST.YEAR = SOURCE.YEAR)This query will add a record in SOURCE into DEST if that record doesnot exist in DEST else it does a update. This query however does notwork on SQL 2000Am I missing something please share your views how I can do this inSQL 2000.ThanksKaren

View 6 Replies View Related

Record Exists Insert Or Update

Oct 25, 2007



I had implemented as in the link to insert or update
http://blogs.conchango.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Checking-if-a-row-exists-and-if-it-does_2C00_-has-it-changed.aspx


What i want to know is... how can i assume there are no duplicate records.
I used Distinct keyword and queried it showed me all are distint but some where i find some duplicates just don't know why i am having when i look at the data both are exactly same...

Please let me know how can i fix it.
Urgent..

Thanks

View 5 Replies View Related

Update Table If Record Exists Else Insert ?

Dec 17, 2007

Is there a way to structure a query to update an existing table record if it already exists, otherwise insert a new record into that table?

View 2 Replies View Related

Checking To See If A Record Exists And If So Update Else Insert

Feb 9, 2007

I've decided to post this as a sticky given the frequency this question is asked.

For those of you wishing to build a package that determines if a source row exists in the destination and if so update it else insert it, this link is for you.

http://blogs.conchango.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Checking-if-a-row-exists-and-if-it-does_2C00_-has-it-changed.aspx

Thanks Jamie!

If you want to do a similar concept to Jamie's blog post above, but with the Konesan's Checksum Transformation to quickly compare MANY fields, you can visit here:
http://www.ssistalk.com/2007/03/09/ssis-using-a-checksum-to-determine-if-a-row-has-changed/

Phil

View 60 Replies View Related

Running An UPDATE Statement Only If A Column Exists

Nov 1, 2007

I'm trying to write a script that would only update a column if it exists.

This is what I tried first:

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Enrollment' AND COLUMN_NAME = 'nosuchfield')
BEGIN
UPDATE dbo.Enrollment SET nosuchfield='666'
END

And got the following error:

Server: Msg 207, Level 16, State 1, Line 1
Invalid column name 'nosuchfield'.

I'm curious why MS-SQL would do syntax checking in this case. I've used this type of check with ALTER TABLE ADD COLUMN commands before and it worked perfectly fine.

The only way I can think of to get around this is with:

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Enrollment' AND COLUMN_NAME = 'nosuchfield')
BEGIN
declare @sql nvarchar(100)
SET @sql = N'UPDATE dbo.Enrollment SET nosuchfield=''666'''
execute sp_executesql @sql
END

which looks a bit awkward. Is there a better way to accomplish this?

View 3 Replies View Related

T-SQL (SS2K8) :: After Update Trigger - Only Insert Records Not Exists

Jul 30, 2014

I have an address table, and a log table will only record changes in it. So we wrote a after udpate trigger for it. In our case the trigger only need to record historical changes into the log table. so it only needs to be an after update trigger.The trigger works fine until a day we found out there are same addresses exist in the log table for the same student. so below is what I modified the trigger to. I tested, it seems working OK. Also would like to know do I need to use if not exists statement, or just use in the where not exists like what I did in the following code:

ALTER TRIGGER [dbo].[trg_stuPropertyAddressChangeLog] ON [dbo].[stuPropertyAddress]
FOR UPDATE
AS
DECLARE @rc AS INT ;

[code]....

View 2 Replies View Related

SQL 2012 :: Delete Rows If Member Does Not Exists In The Member Table

Sep 24, 2015

I have a table where I need to delete rows if the member does not exists in the member table. Will the following syntax work ?

Delete T
FROM Event_Temp_Lead_Screen T
left join member M on ( M.MemberID = T.MemberID )
where
T.Gender is NULL

View 9 Replies View Related

DataSet Rows Being Deleted, But After The Update , The Sql Database Is Not Updated. The Delete Rows Still In The Database.

Jun 4, 2007

 Stepping thru the code with the debugger shows the dataset rows being deleted.
 
After executing the code, and getting to the page presentation. Then I stop the debug and start the
page creation process again ( Page_Load ).    The database still has the original deleted dataset rows.
Adding rows works, then updating works fine, but deleting rows, does not seem to work.
 
The dataset is configured to send the DataSet updates to the database. Use the standard wizard to create the dataSet.
 
 
cDependChildTA.Fill(cDependChildDs._ClientDependentChild, UserId);        rowCountDb = cDependChildDs._ClientDependentChild.Count;               for (row = 0; row < rowCountDb; row++)        {           dr_dependentChild = cDependChildDs._ClientDependentChild.Rows[0];           dr_dependentChild.Delete();                      //cDependChildDs._ClientDependentChild.Rows.RemoveAt(0);           //cDependChildDs._ClientDependentChild.Rows.Remove(0);            /* update the Client Process Table Adapter*/          // cDependChildTA.Update(cDependChildDs._ClientDependentChild);      //     cDependChildTA.Update(cDependChildDs._ClientDependentChild);        }
        /* zero rows in the DataSet at this point */        /* update the Child  Table Adapter */       cDependChildTA.Update(cDependChildDs._ClientDependentChild);

View 1 Replies View Related

Why Would My Int Primary Key Jump To Higher Number

Apr 19, 2008

Why would my int identity primary key column go from one day being 847 and the next number being inserted to 49048?

View 2 Replies View Related

Higher CPU Utilization With SQL Server 2005

Jan 16, 2007

HI
I am facing a strange problem with SQL Server 2005 . The CPU utilization with SQL Server 2005 is higer by about 70% comapared to SQL 2000.

In the same kind of Hardware and with the DB server up , I performed the following tests
Declare @i int
Set @i = 10
While @i < 100000
Begin
Insert into arup_emp values(@i,'M',0)

Set @i = @i + 1
end


The CPU utilization average on SQL 2005 was 45% and on SQL 2K it was just 25% , I am seeing a lot of people who seems to be facing this problem but unfortunately not seeing any solution to this.

Can anyone through some light .
Please note that I have tried to also see the MAXDOP options, but get the same results.

Please help.

Thanks
Arup

View 4 Replies View Related

SSIS Importing XML And Using A TAG From Higher Hierarchy

Sep 25, 2007

I want to read data from a XML into SQL Server database tables "tour" and "stop".
There is a 1:n relation between tour and stop.
(a shortened XML sample, relation Tour : Stop = 1 : n)

<Tour>
<Mandator>mein kunde</Mandator>
<TourNoPlan>TNP_1</TourNoPlan>
<TourNo>1</TourNo>
<Stop>
<StopNo>SN_1</StopNo>
<GPSGeoDec>+8.0000,+48.0000</GPSGeoDec>
</Stop>
<Stop>
<StopNo>SN_2</StopNo>
<GPSGeoDec>+8.3000,+48.5000</GPSGeoDec>
</Stop>
</Tour>

I am able to insert elements from <Tour> into the table "tour" with the data flow in the Integration Services. But I need the values from the tag <TourNoPlan> in the rows for the table stop (it is the foreign key) in the second step. How can I get the values in the SSIS from the <Tour> in the dataflow for the different <stop>? It is a hierarchicle structure - normal for a XML. Is there a sample for reading such a XML into a Database? I have tried it with [Tour::TourNoPlan] or similar, but it was wrong. Second try was setting a UserVariable in the tour dataflow to the actual value of the TourNoPlan and using it in the data flow for the stop tags - but only a setting in a script at PostExecution was possible - to late.
I think a very simple problem and the same for each XML Import. Any ideas ???

Thanks and Best regards
Wolfram

View 1 Replies View Related

How To Get The Value Of System::TaskName Of A Higher Up Level?

May 14, 2007

Hi there,

I was wondering how can I get the value of System::TaskName of a higher scope when I have a Master Package that have several sequence task, data flow tasks and execute package tasks. For each task inside this Master Package on the Post-Execute event handler I have a script task that logs the execution of each task.

After running this master package I saw in my db that I have a row for every single tasks executed in the process and not only the tasks that exist in the master package. For instance, for simplicity let's say my master package looks like this:


SQL Task Script
|
Exec Package 2
|
Exec Package 3
|
Exec Package 4

Package 2,3 and 4 have a SQL Task Script with name Execute SQL Task Package 2, Execute SQL Task Package 3, Execute SQL Task Package 4.

Here's what I got in my db:

Execute SQL Task
Execute SQL Task Package 2
Package2
Execute Package 2
Execute SQL Task Package 3
Package3
Execute Package 3
Execute SQL Task Package 4
Package4
Execute Package 4

I see two TaskName variables in the Variable window, one with OnPostExec scope and the other with Execute Package 2 for instance. I want to get the value of System::TaskName with Execute Package 2 scope.

I want to see in my db only the tasks in bold. Any ideas of how can I do this? I hope you understand what I'm trying to achieve.

Thanks!

View 4 Replies View Related

Migrate Higher Version Of MDAC

Aug 14, 2007

Hi Friends,

I have a system with windows 2000 advanced server SP4 OS. In that system, How can i upgrade MDAC version from 2.5 to 2.8 sp2.


This is use of,
I am going to install sql server 2005 express edition advanced services SP2.

Please help me, how can i upgrade higher version of MDAC?

Thanks in Advance

Rameshkumar Thirumalaisamy

View 5 Replies View Related

Error:... It Requires A Higher Level Edition.

Apr 28, 2006

I've read some threads on this topic and all have been solved by installing the SSIS service. This would be fine except for the fact that I already have SSIS installed and working on the server the package is being called from.

I have several scheduled packages that work without error and a few that fail, telling me "Error: ... it requires a higher level edition." Does SSIS need to be installed on the target server as well? Do I need to do a reinstall? Please advise. Thanks.

-Matt

View 1 Replies View Related

SSIS Higher Level Edition Error When Run In A Sql Job

Dec 27, 2006

Hi,

I am receiving the following error in Sql Job agent when I try to run an SSIS package : The task "Create Excel File" cannot run on this edition of Integration Services. It requires a higher level edition. It then goes on to tell me : The Execution method succeeded, but the number of errors raised (2) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. I have tried reseting the error count to allow for the "errors" , but it stills fails. The job suceeds in Visual Studio, but not when scheduled in Sql Management Studio. Any suggestions?

Thanks,
J.

View 18 Replies View Related

Group By Customer And Item Higher Sale Price?

Mar 5, 2015

I'm developing and sql 2008 view that shows me the last month of sales of every customer and every item sold, the problem is that I need group by customer with the higher Sale Price of every item of the customer, example:

1.If We sold the same item to one customer then it must show just the higher sale price of every item

2.If the same item was sold to the same customer at the same price then it must show just the last sold date record of that item

This is I get :

OrderDate |DebNr|DebName|ItemCode|Descript|Qty|CostPrice|SalePrice|
2015-03-05|0001 |Deb0001|Item-001|Item 001| 3 | 223.10 | 289.00 |
2015-02-25|0001 |Deb0001|Item-001|Item 001| 2 | 220.00 | 286.00 |
2015-03-05|0001 |Deb0001|Item-002|Item 002| 1 | 75.00 | 110.00 |
2015-03-02|0002 |Deb0002|Item-001|Item 001| 1 | 218.00 | 265.00 |
2015-02-27|0002 |Deb0002|Item-001|Item 001| 1 | 218.00 | 265.00 |

This is I need :

OrderDate |DebNr|DebName|ItemCode|Descript|Qty|CostPrice|SalePrice|
2015-03-05|0001 |Deb0001|Item-001|Item 001| 3 | 223.10 | 289.00 |
2015-03-05|0001 |Deb0001|Item-002|Item 002| 1 | 75.00 | 110.00 |
2015-03-02|0002 |Deb0002|Item-001|Item 001| 1 | 218.00 | 265.00 |

This is my code :

SELECT TOP (100) PERCENT OrderDate, DebtorNr, DebtorName, ItemCode, Description, Qty, CostPrice, SalePrice
FROM dbo.VK_SALE_ORDERS
WHERE (OrderDate >= DATEADD(MM, - 1, GETDATE()))
ORDER BY DebtorNr, ItemCode

View 2 Replies View Related

Under What Kind Of Circumstances,the LSN On The Page Is Higher Than The Actual LSN For This Log Record

Aug 16, 2007

I'm reading <inside sql server 2005torage engine> recently.

The author mentioned about " If the LSN on the page is equal to or higher than the actual LSN for this log record, SQL Server will skip the REDO operation" in chapter 5 and section 1.

As we all know,the transaction log will be written before the changes to the database are written.
So i think the the LSN on the page is equal to or lower than the actual LSN for this log record....

Any suggestions?

View 3 Replies View Related

I Don't Suppose BULK UPDATE Exists?... Like BULK INSERT?

Sep 27, 2007

I have to update a field within a table of 60 records or so. Each record has a different field value. it's type varchar. i was given an excel file with the field values and was thinking of a bulk update like bulk insert, but i don't recall that it's possible that way.

Is the only way to create a table, bulk insert, then merge the two tables together with UPDATE?

Just wanted to see if there was an easier way to do it, otherwise i'll take the latter route. Thanks!

View 1 Replies View Related

SQL Server Admin 2014 :: Heap Table Fragmentation Is Higher Than 50

Dec 1, 2014

I have bunch of heap tables and the fragmentation seems to be high, i am not sure whether i shall add index for them, as these tables are inserted and updated every day.

View 4 Replies View Related

Update Rows

Apr 22, 2008

Hi,
I have a table called Past with 4 columns(Number,WW,Goal,Eng) and in Number column has 53 rows, 1,2,3 - 53. Now i need to update the 53rd row with the following code and it works. Since i dont know how to combine this i update them separately.

Update Past
set WW = ('WW'+convert(varchar(10),datepart(wk,getdate())-1))
WHERE Number = '53'

Update Past
set Goal = (Select Eng_Goal from AverageEngTime)
WHERE Number = '53'

Update Past
set Eng = (SELECT ((Mon_Day + Mon_Night + Tue_Day + Tue_Night + Wed_Day + Wed_Night + Thu_Day + Thu_Night + Fri_Day + Fri_Night + Sat_Day + Sat_Night + Sun_Day + Sun_night)* 100/168) FROM AverageEngTime where Shifts = 'Average')
WHERE Number = '53'

Now, whenever i execute, I want my row 52 to be updated with data from row 53 and row 51 with data from row 52 and so on until row 1 with data from row 2. Meaning i just want to update new data for row 53 and other rows should be updated with the data from next line. How do i do that? Please help..Thanks

View 1 Replies View Related

Update N Rows

Mar 22, 2006

Hi,I'm using table it has 100 rows, how can i update 10 or 15 rows at thesame time with single query. In real case, if user enters "5" intextbox it means that the "5" rows will be updated.In SAS i was using 'outobs' {outobs = n} which means n rows will beaffected.Thanx.

View 7 Replies View Related

Update Only One Of Two Identical Rows

Oct 29, 2006

Hello,I ended up with two identical rows in one table. They should have differences but I cannot update one, as it tries to update both of them, or throws an error. How to update only one row, and leave other as is?

View 10 Replies View Related

Update Multiple Rows

May 13, 2004

Any idea how to fix my code. I am getting this error message below....


Server: Msg 512, Level 16, State 1, Procedure TrigRetReqRecIDP1, Line 11
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.




Set @intRowCount = (select count(*) from RequestRecords where REID = @REID)
While (select @REID from RequestRecords) != @intRowCount
Begin
select @intRRID = (select REID from RequestRecords where REID=@REID and RRStatus = 'PE')
Exec TrigAssignImpTaskNewP1 @intRRID, @REID
End

View 2 Replies View Related

Update Rows From Another Table

Aug 24, 2007

Hi

I would like update the rows of table 1 with the values in table2 see below based on a matching ID. I don’t want to update the ID field as this would be a violation of the primary key I assume as ID is a primary key, just the FirstName and SecondName fields need updating.

Table1
(ID, FirstName, Surname)
Table 2
(ID, FirstName, Surname)

Any ideas?
Cheers

View 6 Replies View Related

How To Update Multiple Rows At Once

Aug 10, 2005

ok my data base has 4 columns id,fname,lname,email and 3 rows 1,2,3
I made a simple update form that accesses the data and displays all three rows with the data in them:

<cfquery name="QUIZ" datasource="test">
SELECT id,fname,lname,email
FROM info
order by id
/cfquery
<HTML>
<HEAD>
<TITLE>Update an Employee</TITLE>
</HEAD>
<BODY>
<H1>Update an Employee</H1>
<FORM ACTION="databaseupdater.cfm" METHOD="POST">
<cfoutput query="QUIZ">
<INPUT TYPE="hidden" NAME="id" VALUE="#id#">
<P>
First name:
<INPUT TYPE="text" NAME="fname" SIZE="15" MAXLENGTH="30" VALUE="#Trim(fname)#">
<BR>
Last name:
<INPUT TYPE="text" NAME="lname" SIZE="15" MAXLENGTH="30" VALUE="#Trim(lname)#">
<BR>
E-Mail:
<INPUT TYPE="text" NAME="email" SIZE="15" MAXLENGTH="30" VALUE="#Trim(email)#">
<P>
</cfoutput>
<INPUT TYPE="submit" VALUE="update">
<INPUT TYPE="reset" VALUE="Clear">
</FORM>
</BODY>
</HTML>

you can use this form to send the updated data to databaseupdater.cfm:

<CFQUERY
DATASOURCE="test"
>
UPDATE info
SET fname='#fname#',
lname='#lname#',
email='#email#'
</CFQUERY>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
Thank You
</body>
</html>

the problem Grieg RN is each column in the database gets updated with all 3 rows of data in each column in stead of seperating the data in its correct row and column. I don't know much about the problem im just starting out please help. Thanks

View 5 Replies View Related

Update Multiple Rows - Not Getting It Right

Jan 3, 2006

Hi all,

I need to write an SQL statement to update multiple row (all) as follws and can just not get it right please help.

I have two fileds - "Tilte" and "Title1" in my "notes" table.

I would like to run through the entire table and replace the information in "Title1" with that of "Title", also I need to change a character whilst doing so , ie change a "=" to a "-"

Example
Title - "Will is coming to town = Paul"

need to copy this to Title1 and it must change to...

Title1 - "Will is coming to town - Paul"

Running MS SQL2000 SP4

Help appriciated
Thanks

View 3 Replies View Related







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