Capture The ID Of The Last Record Entered And Use In An Update
Apr 13, 2007
I'm entering a Selection record for a partiuclar lotID,
Once entered, I need to obtain its SelectionID then use it to update a another field within that record.
Here's what I've been doing...
--insert values into a testchangeorders table
INSERT INTO testchangeorders VALUES (2,3,3,3,1,'red',0,5)
--Find the SelectionsID of the last record created for that partiuclar LotID
SELECT MAX (SelectionsID)
FROM testchangeorders
WHERE LotID = 2
--Once located, I was trying to update a field called uniqueID with a contantination of '3-' & the record's SelectionsID
UPDATE testchangeorders
SET UniqueID = ('3-' & SelectionID
WHERE SelectionsID = SELECT MAX (SelectionsID) AND LotID = 2)
View 7 Replies
ADVERTISEMENT
Aug 8, 2007
im trying to summarize all records except the last one entered.
ex
-column001-
1
2
3
4
5
6
the output should be "15" (1+2+3+4+5) is this possible?
One thing i tryed is to put in autodate and time and then count them and leaveout the newest one. Well i can't make it work...
Thx for all help
View 4 Replies
View Related
Nov 20, 2007
Hi every one
I want to get the currently entered or updated record in the database table by using SQL Query or stored procedure.
Thanx in advance
Take care
Bye
View 3 Replies
View Related
Jan 2, 2007
Dear All,
What's the most efficient way of joining a 1 to many relation, where a record in table A will have multiple records in table B.
I'd like to select every record in table A but only joining the last relevant record from table B. So:
Table A:
A1 Prj1
A2 Prj2
Table B:
B1 A1 23/12/2005
B2 A1 26/12/2005
B3 A1 2/1/2007
B4 A2 25/12/2006
B5 A2 1/1/2007
So I'd like to list using the most efficient way this:
A1 Prj1 B3 2/1/2007
A2 Prj2 B5 1/1/2007
I'm assuming this is NOT the most efficient way:
select A, (select top 1 date from B orderBy ...)
Any suggestions?
View 6 Replies
View Related
Nov 22, 2006
Im trying to add a new rcord to my db on a button click usign the following code
'data adapter
Dim dAdapt1 As New SqlClient.SqlDataAdapter
'create a command object
Dim objCommand As New SqlClient.SqlCommand
'command builder
Dim builderT As SqlClient.SqlCommandBuilder
'connection string
Dim cnStr As String = "Data Source=ELEARN-FRM-BETA;Initial Catalog=StudentPlayGround;Integrated Security=True"
'dataset
Dim dsT As DataSet
Private Sub connect()
'connection
objCommand.Connection = New SqlClient.SqlConnection(cnStr)
'associating the builder with the data adapter
builderT = New SqlClient.SqlCommandBuilder(dAdapt1)
'opening the connection
objCommand.Connection.Open()
'query string
Dim query As String = "SELECT * from StudentPlayground..Employees"
'setting the select command
dAdapt1.SelectCommand = New SqlClient.SqlCommand(query, objCommand.Connection)
'dataset
dsT = New DataSet("Trainee Listings")
dAdapt1.Fill(dsT, "Employees")
End Sub
Private Sub BindData()
connect()
DataBind()
End Sub
Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
Dim empID As Integer = CType(FindControl("TextBox8"), TextBox).Text
BindData()
Dim firstName As String = CType(FindControl("TextBox1"), TextBox).Text
BindData()
Dim lastName As String = CType(FindControl("TextBox2"), TextBox).Text
BindData()
Dim location As String = CType(FindControl("TextBox3"), TextBox).Text
BindData()
Dim termDate As Date = CType(FindControl("TextBox4"), TextBox).Text
BindData()
Dim hireDate As Date = CType(FindControl("TextBox7"), TextBox).Text
BindData()
Dim dept As String = CType(FindControl("TextBox5"), TextBox).Text
BindData()
Dim super As String = CType(FindControl("TextBox6"), TextBox).Text
BindData()
Dim newRow As DataRow = dsT.Tables("Employees").NewRow
newRow.BeginEdit()
newRow.Item(0) = empID
newRow.Item(1) = firstName
newRow.Item(2) = lastName
newRow.Item(3) = location
newRow.Item(4) = hireDate
newRow.Item(5) = termDate
newRow.Item(6) = dept
newRow.Item(7) = super
newRow.EndEdit()
'do the update
Dim insertStr As String = "INSERT INTO Employees" + _
"(EmployeeID,FirstName,LatName,Location,HireDate,TerminationDate,Supervisor)" + _
"VALUES (empID,firstName,lastName,location,hireDate,termDate,dept,super)"
Dim insertCmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(insertStr, objCommand.Connection)
dAdapt1.InsertCommand() = insertCmd
dAdapt1.Update(dsT, "Employees")
'Dim insertCmd As new SqlClient.SqlCommand = (builderT.GetInsertCommand()).ToString())
'dAdapt1.InsertCommand = New SqlClient.SqlCommand(insertCmd.ToString(), objCommand.Connection)
BindData()
objCommand.Connection.Close()
objCommand.Connection.Dispose()
End Sub
im not sure wats going wrong because the record is not being added. Please help!!
View 4 Replies
View Related
Oct 22, 2005
My form has an optional field for date entry. If user did not enter anything then how can I still maintain null value in the table in an update operation? Thanks for advice.
View 14 Replies
View Related
Aug 15, 2007
How t o capture a header record from a flat file and write it to
different table.
It seems that Conditional Split task doesn't work because it detects the different layout and errors out.
any help would be appreciated.
thanks
View 3 Replies
View Related
Mar 28, 2008
I have 2 SQL server 2000 machines, I need to take a table from each one and combine them together based on a date time stamp. The first machine has a database that records information based on an event it is given a timestamp the value of variable is stored and a few other fields are stored in Table A. The second machine Table B has test data entered in a lab scenario. This is a manufacturing facility so the Table A data is recorded by means of a third party software. Whenever a sample is taken in the plant the event for Table A is triggered and recorded in the table. The test data may be entered on that sample in Table B several hours later the lab technician records the time that the sample was taken in Table B but it is not exact to match with the timestamp in Table A. I need to combine each of these tables into a new SQL server 2005 database on a new machine. After combining the tables which I am assuming I can based on a query that looks at the timestamp on both Tables A & B and match the rows up based on the closest timestamp. I need to continuously update these tables with the new data as it comes in. I havent worked with SQL for a couple of years and have looked at several ways to complete this task but havent had much luck. I have researched linked servers, SSIS, etc Any help would be greatly appreciated.
View 10 Replies
View Related
Nov 4, 2007
Hi guys,
A column in my table is being updated and I would like to find out what process, host, user, etc. is performing the update.
I have added a trigger to the table so that when an update occurs I am able capture the session details into a table, however the session details that are being returned are those of the actual trigger rather than those of the original query.
The statement that I am using to capture the session details is...
select * from sys.dm_exec_connections cross apply sys.dm_exec_sql_text(most_recent_sql_handle) where session_id = @@spid
There is a parent_session_id returned in the above which I hoped might give me some pointers but this is always NULL.
I have been working my way through the system dynamic views in the hope that one of them will provide the information I am looking for but so far I've had no luck.
Because the system I am troubleshooting is web based the actual server and user details will be those configured as service accounts for the application but if I am able to show the developers the original query that was used for the update I'm sure they will be able to provide valuable information as to which component it is coming from. I imagine SQL will also be able to tell me which host is sending the query. With these two bits of info I'm sure I'll be able to track it down.
Our suspicion is that an old component is running somewhere and I'd like to be able to track it down. Perhaps I've spent too much time looking at this but I'm coming to the conclusion that it may not be possible from the SQL back end, which I am very surprised at.
I have tried capturing every session that was running at the time of the update but there's simply too much info to deal with. I even searched through these results but there's so many different possible combinations that an update statement might take form that it quickly became a worthless exercise.
Perhaps one of you can resolve this for me. Any ideas?
Regards,
Joe
View 7 Replies
View Related
Sep 13, 2007
I have built a SSIS package that bascially updates two columns in table A...the update statement reads;
update Table A
set Colum 1 = ?,('?' is a variable)
Column 2 = ?
In my SSIS package, I would like to be notified/capture, if one or both variables are null....How do I do that ?..error log ?
The package runs fine both ways (if variables are null or not)
Thank you
View 1 Replies
View Related
May 28, 2015
I am trying to update a table and then also use OUTPUT clause to capture some of the columns. The code that I am using is something like the one below
UPDATE s
SET Exception_Ind = 1
OUTPUT s.Master_Id, s.TCK_NR
INTO #temp2
FROM Master_Summary s
INNER JOIN Exception d
ON d.Id = LEFT(s.Id, 8)
AND d.Barcode_Num = s.TCK_NR
WHERE s.Exception_Ind IS NULL
The above code is throwing an error as follows:
Msg 4104, Level 16, State 1, Procedure Process_Step3, Line 113
The multi-part identifier "s.Master_Id" could not be bound.
Msg 4104, Level 16, State 1, Procedure Process_Step3, Line 113
The multi-part identifier "s.TCK_NR" could not be bound.
View 5 Replies
View Related
Mar 23, 2015
I have located a bug in the functions cdc.fn_cdc_get_net_changes_<capture_instance> generated when you enable cdc on a table. This bug can be triggered if 2 rows are created in the _CT table having the same values for the __$start_lsn, __$seqval and the table's key column(s). From research on the internet I have found such rows can be created by a "deferred update": a single update statement in which a column that is part of a unique constraint is updated.
In order to report the bug with Microsoft I need to create a complete series of steps-to-reproduce. But even though the situation happens several times a day in our production environment, I have not yet been able to reproduce it in my test environment.I need a single update statement (plus maybe some steps in advance) that make that the log reader inserts 2 rows into the _CT table, one with __$operation = 1 (delete) and another with __$operation = 2 (insert) as opposed to the single row with __$operation = 4 that it inserts for a normal update. Below is the script I have so far to create a fresh database, enable cdc, create a test table, insert some data and update this data.
I would have liked the last update statement to be handled as a "deferred update". However in all of my tests the log reader just simply inserts a single row into the cdc.dbo_NETTEST_CT table.how to reproduce the situation where I get the 2 rows with __$operation 1 and 2 from a single update statement instead of the single row with __$operation = 4.
CREATE DATABASE [cdcnet]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'cdcnet', FILENAME = N'S:SQLDATAcdcnet.mdf' , SIZE = 4096KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'cdcnet_log', FILENAME = N'T:SQLLOGcdcnet_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
[code]....
View 4 Replies
View Related
Aug 16, 2006
I am trying to update a record in a table based off of criteria of another record in the table.
So suppose I have 2 records
ID owner type
1 5678 past due
2 5678 late
So, I want to update the type field to "collections" only if the previous record for the same record is "past due". Any ideas?
View 5 Replies
View Related
Mar 26, 2008
Hi All,
I am trying to create package something like that..
1- New Customer table as OleDB source component
2- Lookup component - checks customer id with Dimension_Customer table
3- And if same customer exist : I have to update couple fields on Dimension_Customer table
4- if it does not exist then I have insert those records to Dimension_Customer table
I am able to move error output from lookup to Dimension_Customer table using oledb destination
but How can I update the existing ones?
I have tried to use oledb command but somehow it didnt work
my sql was like this : update Dimension_Customer set per_X='Y', per_Y= &Opt(it should come from lookup)
I will be appreciated if you can help me...
View 3 Replies
View Related
Jan 3, 2005
hi!
I have a big problem. If anyone can help.
I want to retrieve the last update time of database. Whenever any update or delete or insert happend to my database i want to store and retrieve that time.
I know one way is that i have to make a table that will store the datetime field and system trigger / trigger that can update this field record whenever any update insert or deletion occur in database.
But i don't know exactly how to do the coding for this?
Is there any other way to do this?
can DBCC help to retrieve this info?
Please advise me how to do this.
Thanks in advance.
Vaibhav
View 10 Replies
View Related
Jun 6, 2007
I am looking for some guidence on the following.
when i click the save button, The record should be updated to the table. I have produced the code below which does'nt seem to work. Please guide me
It works fine when i hard code the value for "textbox value" in line SqlDataSource1.UpdateParameters.Item("PrmVal").DefaultValue = "Textbox value"
Protected Sub SaveRecord(ByVal sender As Object, ByVal e As System.EventArgs) If Page.IsValid Then SqlDataSource1.UpdateParameters.Item("PrmVal").DefaultValue = Textbox value SqlDataSource1.Update() end ifend sub
<form id="form1" runat="server"> <div> </div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BmsConnectionString %>" SelectCommand="SELECT [PrmGrp], [PrmCde], [PrmVal], [PrmValArb], [GrpDsc] FROM [PrmDef] WHERE (([PrmGrp] = @PrmGrp) AND ([PrmCde] = @PrmCde))" UpdateCommand="UPDATE PrmDef SET PrmVal=@PrmVal, PrmValArb=@PrmValArb, GrpDsc=@GrpDsc,RecSts=1 WHERE (([PrmGrp] = @PrmGrp) AND ([PrmCde] = @PrmCde))"> <SelectParameters> <asp:QueryStringParameter Name="PrmGrp" QueryStringField="PrmGrp" Type="String" /> <asp:QueryStringParameter Name="PrmCde" QueryStringField="PrmCde" Type="String" /> </SelectParameters> <Updateparameters> <asp:parameter Name="PrmGrp" /> <asp:parameter Name="PrmCde" /> <asp:parameter Name="PrmVal" /> <asp:parameter Name="PrmValArb" /> <asp:parameter Name="GrpDsc" /> <asp:parameter Name="RecSts" /> </Updateparameters> </asp:SqlDataSource> <asp:FormView ID="FormView1" runat="server" DataKeyNames="PrmGrp,PrmCde" DataSourceID="SqlDataSource1" DefaultMode="Edit" Width="670px" style="left: 12px; position: relative; top: 12px; z-index: 100;" Height="359px" BorderStyle="Double" BorderWidth="5px" CaptionAlign="Top" GridLines="Both" BorderColor="Maroon" CellPadding="2"> <EditItemTemplate> <br /> Parameter Group: <asp:Label ID="PrmGrp" runat="server" Text='<%# Eval("PrmGrp") %>' style="left: 34px; position: relative; top: 0px" Width="125px"></asp:Label><br /> <br /> Parameter Code: <asp:Label ID="PrmCde" runat="server" Text='<%# Eval("PrmCde") %>' style="left: 40px; position: relative; top: 0px" Width="125px"></asp:Label> <br /> <br /> English description: <asp:TextBox ID="PrmValTextBox" runat="server" Text='<%# Bind("PrmVal") %>' style="left: 17px; position: relative; top: 0px" Width="318px"></asp:TextBox> <br /> Arabic description: <asp:TextBox ID="PrmValArbTextBox" runat="server" Text='<%# Bind("PrmValArb") %>' style="left: 25px; position: relative; top: 0px" Width="317px"></asp:TextBox><br /> <br /> Group description: <asp:TextBox ID="GrpDscTextBox" runat="server" Text='<%# Bind("GrpDsc") %>' style="left: 29px; position: relative; top: 4px" Width="316px"></asp:TextBox><br /> <br /> <asp:Button ID="CmdSave" runat="server" OnClick="SaveRecord" Style="left: 134px; position: relative; top: 49px" Text="Save" Width="72px" /> <asp:Button ID="CmdDelete" runat="server" OnClick="DeleteRecord" Style="left: 145px; position: relative; top: 50px" Text="Delete" Width="79px" /> <asp:Button ID="CmdClose" runat="server" OnClick="CloseWindow" Style="left: 160px; position: relative; top: 48px" Text="Close" Width="73px" /><br /> <br /> <asp:Label ID="ErrLabel" runat="server" Font-Bold="True" Font-Size="Small" ForeColor="#C00000" Style="left: 148px; position: relative; top: -38px" Text="Fields marked as (*) are required" Visible="False" Width="318px"></asp:Label><br /> </EditItemTemplate> <ItemTemplate> PrmGrp: <asp:Label ID="PrmGrpLabel" runat="server" Text='<%# Eval("PrmGrp") %>'></asp:Label><br /> PrmCde: <asp:Label ID="PrmCdeLabel" runat="server" Text='<%# Eval("PrmCde") %>'></asp:Label><br /> PrmVal: <asp:Label ID="PrmValLabel" runat="server" Text='<%# Bind("PrmVal") %>'></asp:Label><br /> PrmValArb: <asp:Label ID="PrmValArbLabel" runat="server" Text='<%# Bind("PrmValArb") %>'></asp:Label><br /> GrpDsc: <asp:Label ID="GrpDscLabel" runat="server" Text='<%# Bind("GrpDsc") %>'></asp:Label><br /> </ItemTemplate> <HeaderStyle BorderStyle="Double" BackColor="#FFC0C0" BorderWidth="5px" BorderColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" /> <HeaderTemplate> Business parameter(Edit) </HeaderTemplate> <RowStyle BorderWidth="5px" /> </asp:FormView> </form>
View 4 Replies
View Related
Jul 18, 2007
Hi everybody,I am using SQL Server 2005. I have a table which currently has only 1 record. I am unable to update any field for this particular record and SQL server is timing out and giving an error message saying No row was updated. I created another record in the table and tried to update the fields in the new record without any problem. I am unable to update any field only for the 1 record in the table using my application, query window sql statement as well as directly changing the in the database.Can anybody please help me.thanks in advance,Murthy here
View 3 Replies
View Related
May 15, 2008
I am in a situation in which I would like to update my one table three column with other table three column, The other table might have more then one record but I would like to have the TOP 1 record of that table for these column. How can I achive it. I know I will be able to achive by writing three statment like
Update abc
set a=(select top 1 a from xyz order by ),
b=( select top 1 b from xyz) and so but not sure that a and b using the same record and thats the requirment of update is
any help much apprecited
View 1 Replies
View Related
Jul 23, 2005
Hello,update table set column = x where b is nullI have the above update statement in a transact sql file. I would liketo change it so that it will only update 1 of the records in the table,even if there are many records where b is null....Any ideas would be great.Many thanks,Allan
View 1 Replies
View Related
Jul 23, 2005
HiI've a table with 2 columns, one for a client code and one for adate/time and could be more than one record with the same client codeand date/time. the 3rd column is another date/time, NULL by default.I need to check if exists records for a determinated client code anddate/time and place the current date/time in the 3rd column for just oneand only one record.Is this possible ? How ?Thanks in advanceJ
View 9 Replies
View Related
Feb 1, 2008
I'm very surprised since I cannot do a simple update operation...
Seems that the cursor after a Read, Readfirst, ReadLast or ReadPrevious is gone...
Here is a possible sequence from the user's standpoint.
1) Performs a QBE search
cmd_Logbook_search = Conn_User.CreateCommand()
cmd_Logbook_search.CommandText = sql_Logbook
rset_Logbook = cmd_Logbook_search.ExecuteResultSet(ResultSetOptions.Updatable Or ResultSetOptions.Scrollable)
-----
If rset_Logbook.HasRows = False Then Exit Sub
rset_Logbook.ReadFirst()
Me.Fill_Logbook_TextBoxes()
2) Navigates
Try
If True = rset_Logbook.Read() Then
Me.Fill_Logbook_Textboxes()
Else
rset_Logbook.ReadLast()
Me.Fill_Logbook_Textboxes()
End If
Catch ex As Exception ' esta excepción se levanta si el recordset está vacio
MessageBox.Show(m11, m1, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End Try
3) Update the record
If Result = DialogResult.Yes Then
Try
rset_Logbook.SetValue(rset_Logbook.GetOrdinal("Altitude"), Me.TextBox_Altitude.Text)
rset_Logbook.Update()
MessageBox.Show("OK", m1, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
Catch ex As Exception
MessageBox.Show(ex.message, m1, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End Try
End If
And I always gets a "No data exist for row/colum" so...where did the cursor gone?
Any help, please I need to move forward! Thanks a lot in advance!!
View 7 Replies
View Related
Jul 10, 2007
Hi
I am new to visual studio and I am attempting to edit records held in mysql, the code below runs and throws no errors "strAdd" is underlined and says that it is used before it has been given a value! But If I debug.print(strAdd) I get the expected string returned. What do I need to do to get the updated records saved?
' code
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim StrAdd as string
cn = New ADODB.Connection
cn.ConnectionString = "Provider=SQLNCLI;" _
& "Server=(local);" _
& "Database=customerlink;" _
& "Integrated Security=SSPI;" _
& "DataTypeCompatibility=80;" _
& "MARS Connection=True;"
Dim mySQL As String
mySQL = "SELECT *" & _
" FROM tblvsol" & _
" Where RevStatus = " & 0 & _
" And GeoCodeStatus = " & 1
cn.Open()
rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.CursorType = ADODB.CursorTypeEnum.adOpenDynamic
.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
.Open(mySQL)
End With
Do While Not rs.EOF
Code here finds the value for the string variable €˜atrAdd€™
strAdd = New Value
If Not strAdd Is Nothing Then
rs.Fields("location").Value = strAdd
rs.Fields("RevStatus").Value = 1
rs.Update()
else
end if
loop
Regards
Joe
View 9 Replies
View Related
Feb 22, 2008
How do I tell an update query to do the update only to one row in the table, and if there s more than one row in the where clause, then not to do the update.
Something like this:
update top 1 set myCol='value' where searchCol='criteria'
But that causes an error.
View 6 Replies
View Related
May 4, 2004
Hello,
I was stuck when update database using SqlDataAdapter. I have several textboxes in my webform1. When wepform1 is loaded, they will display user's information. The user can only input content in two textboxes. When user clicks the update button, I hope to update this record in SQL Server 2000 database. However, the program didn't work. There was no error message reported but when I stepped into the code, I found out that dataadapter's update method didn't succeed. I got 0 rows affected. Can I get some advice from someone ?
Here is the code:
string StrUpdateCmd = "Update Table1 Set Hphone = @Hphone, Cphone = @Cphone, Team = @Team Where emailname =@emailname ";
SqlDataAdapter UpdateDa = new SqlDataAdapter("Select * from Table1",SqlConnection1);
UpdateDa.UpdateCommand = new SqlCommand(StrUpdateCmd, SqlConnection1);
//Add parameters of update command.
SqlParameter prm1 = UpdateDa.UpdateCommand.Parameters.Add("@Hphone",SqlDbType.NVarChar, 16);
prm1.Value = txtHphone.Text ;
SqlParameter prm2 = UpdateDa.UpdateCommand.Parameters.Add("@Cphone",SqlDbType.NVarChar, 16);
prm2.Value = txtCphone.Text ;
SqlParameter prm3 = UpdateDa.UpdateCommand.Parameters.Add("@Team",SqlDbType.NVarChar, 16);
prm3.Value = this.DropDownList1.SelectedItem.Value ;
SqlParameter prm4 = UpdateDa.UpdateCommand.Parameters.Add("@emailname",SqlDbType.NVarChar, 50);
prm4.Value = txtEmail.Text;
try
{
DataSet dataset2 = new DataSet();
//Open database connection.
SqlConnection1.Open();
dataset2.Clear();
UpdateDa.Fill(dataset2, "Table1");
this.DataGrid1.DataSource = dataset2.Tables[0] ;
DataGrid1.DataBind ();
//Update database
int ret =UpdateDa.Update(dataset2,"Table1");
if( ret == 1 )
{
ShowMessage("Update succeed!");
}
else
{
ShowMessage("There is an error in updating ");
}
UpdateDa.Fill(dataset2);
//Show data after update.
this.DataGrid1.DataSource = dataset2;
DataGrid1.DataBind ();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sqlConnection1.Close();
}
View 1 Replies
View Related
Oct 14, 2001
Can anyone help with an effective way in retriving the id of the new record before input of any data into a form. We have a form where a few of the controls recordsource requires the new record id before they will display correctly. I have tried various ways to trigger the form afterupdate event in the hope that the id will be returned but get the error message "The data will be added to the database but the data won't be displayed in the form because it doesn't satisfy the criteria in the underlying recordsource"
Thanks in advance
View 1 Replies
View Related
Jul 12, 2007
This should be incredibly simply but I've been working on it for quite a while and have had no luck:
There's ONE table with many columns but I'm only interested in three columns.
DistrictLEA
SSN
And a third column titled DistrictLEASSN
This is an odd scenario but I need to concatenate DistrictLEA + SSN for each record and update DistrictLEASSN with the result.
Is there a good method to do this with T-SQL/Cursors?
UPDATE DistrictLEASSN
SET DistrictLEASSN= DistrictLEA + SSN
I'd like to loop through each record in the table and perform the operation.
Thanks! -CD
View 6 Replies
View Related
Mar 4, 2005
here is my trigger that i have right now the only problem is that it deletes the records before copying everything into the db i dont what do delete everything i just whant to catch the updated record and then update the other tables same record in the other db how would i do this:
right now i have this
CREATE TRIGGER test ON [dbo].[TEST123]
AFTER INSERT, UPDATE, DELETE
AS
IF @@ROWCOUNT = 0
RETURN
IF (COLUMNS_UPDATED() & 2 = 2)
DELETE FROM pubs..TEST123 WHERE test3 = '300'
INSERT INTO pubs..TEST123
SELECT * FROM TEST123 WHERE test3 = '300'
UPDATE pubs..TEST123 SET test1 = 'X' WHERE test1 IS NULL AND test3 = '300'
UPDATE pubs..TEST123 SET test2 = 'X' WHERE test2 IS NULL AND test3 = '300'
UPDATE pubs..TEST123 SET test3 = 'X'
View 2 Replies
View Related
Mar 23, 2006
Hi everybody,
I have 2 fields in a table.
Table Name--- StudentDetail
Name Address
Saju Kerala
Balaji Bangalore
Raj Kumar Tamilnadu
Saju Kerala
I want to Update one of the duplicate row as I don't have any unique id column. So can anybody update one of the the duplicate record without using any id or altering any column.
I am waiting for your reply.................
Regards,
Saju S.V
View 1 Replies
View Related
Mar 31, 2008
Hi
I have a column in a table which has html text. Eg
<p>[Video:-123xyz] <br />A video showing blah blah</p>
I wish to update the data between the two square brackets within the rest of the text to:
<p>[View:http://www.video123.com/-123xyz] <br />A video showing blah blah</p>
...so basically i need to find all occurrences of '[Video:' and replace it with '[View:http://www.video123.com/' .
Please can someone point me in the right direction?
cheers
View 14 Replies
View Related
Apr 20, 2004
Please tell me how to code the Update of the current cursor record as one would do using VD/ADO :
VB: Table("Fieldname") = Value
----------------------------------------------------------
Declare @NextNo integer
Select @NextNo = (Select NextNo from NextNumbers where NNId = 'AddressBook') + 1
--Create a Cursor through wich to lo loop and Update the ABAN8 with the corrrect NextNo
DECLARE Clone_Cursor CURSOR FOR Select ABAN8 from JDE_Train.trndta.F0101_Clone
Open Clone_Cursor
Fetch Next from Clone_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
Select @NextNo = @NextNo + 1
Clone_Cursor("ABAN8") = @NextNo
Update Clone_Cursor
FETCH NEXT FROM Clone_Cursor
END
CLOSE Clone_Cursor
DEALLOCATE Clone_Cursor
GO
View 1 Replies
View Related
May 30, 2008
Using trigger
want to update a field being inserted from another record in the same table.
the record being inserted I want to pull the bkjrcode from another record where the account = 1040 that also has the same ord# and inv# as the record being inserted.
Here is what I've tried with no luck.
create trigger [updategbkmut] on [dbo].[gbkmut]
after insert
as
update g1
set g1.bkjrcode = g2.bkjrcode
from gbkmut g1
inner join inserted i
on i.ord_no = g1.ord_no and i.inv_no = g1.inv_no
inner join gbkmut g2
on i.ord_no = g2.ord_no and i.inv_no = g2.inv_no
where i.freefield3 = 'Rebate' and g1.account = '1040'
View 2 Replies
View Related
Jun 9, 2008
I have a queue in service broker, which gets messages with a stored procedure which is invoked from VS application. The messages are properly stored in queue. I want to receive these messages one after the other and put it into a table. I am fetching the messages in a while loop which breaks when messages are over.
The first record is inserted properly. In the next iteration of the loop I want to append the next message data in that same record. This will continue for approximately 10 minutes after which a new record will be created. When I attempt to append the data in first record that record is not being read even though I have used isolation level read uncommitted.
What is it that I am missing to achieve the desired results?
Gouri Sohoni
View 4 Replies
View Related
Mar 13, 2014
We are developing a database in SQL and we are trialing some of our typical analysis undertaken on out dataset.
I have a problem with a update function. ID direction Holiday Lat Long Speed obstime - Datestamp LicenseID - varchar(7) status - int (0 or 1) O-Unoccipied, 1-occupied Pickup - Boolean Dropoff - Boolean
I am trying to update the 'Pickup' or 'Dropoff' when the status changes from 0 to 1 or from 1 to 0 if the difference in the datestamp is less than 2 minutes. Pickup is when the status goes from 0 to 1 Drop off is when the status goes from 1 to 0
View 2 Replies
View Related