Deleting An Entry During Run-time

Jan 2, 2007

I am trying to delet a row duing run-time but everytime i go to save the program I get an error message saying: "Update Requires a valid DeleteCommand when passed DataRow collection with deleted row.

Anyone any ideas?

View 3 Replies


ADVERTISEMENT

T-SQL (SS2K8) :: Deleting Only 1 Row At A Time Instead Of Using Condition And Deleting Many Rows?

Jul 18, 2014

/****** Object: StoredProcedure [dbo].[dbo.ServiceLog] Script Date: 07/18/2014 14:30:59 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[ServiceLogPurge]

-- Purge records dbo.ServiceLog older than 3 months:
-- Purge records in small portions to avoid locking production tables
-- for a long time. The process takes longer, but can co-exist with
-- normal usage of the tables.

[Code] ...

*** Getting this error below when executing the code ***

Msg 102, Level 15, State 1, Procedure ServiceLogPurge, Line 45
Incorrect syntax near 'Failed:'.

View 9 Replies View Related

Help Writing Query (find The Entry With The Closest Time Given A Time)

May 26, 2005

Hi,

I have a table which has a few fields, one being "datetime_traded". I need to write a query which returns the row which has the closest time (down to second) given a date/time. I'm using MS SQL.

Here's what I have so far:


Code:


select * from TICK_D
where datetime_traded = (select min( abs(datediff(second,datetime_traded , Convert(datetime,'2005-05-30:09:31:09')) ) ) from TICK_D)



But I get an error - "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.".

Does anyone know how i could do this? Thanks a lot for any help!

View 2 Replies View Related

Adding Entry To DB And Getting Unique ID At The Same Time

Jul 20, 2005

Hi all,I'm writing a website with Cold Fusion and when a user submits arequest and it's stored in the MS SQL database, I want the unique ID(Identity field in table) to be given to the user on screen plusemailed to user.Now can I store data to the database (where the ID is created) andreturn this as a variable in the same statement? I've seen this doneon many websites, but I have no idea how to do it in one step.Thanks,Alex.

View 1 Replies View Related

Can I Select Subset Based On Time Of Entry

Jul 5, 2001

A table gets data every 4 minutes, I only need spread of every 15 minutes. Can I select only records spread every 15 minutes apart from this table without having to run a scheduled job every 15 minutes and loading one record closest to getdate() at that point into another table(this is how I am doing it now) Is there a better way. Please help
Thanks

View 2 Replies View Related

Deleting Records From 2 Tables At The Same Time

May 29, 2008

Hello all,
I have a DTS package set up to import a text file on a daily basis. I need to dump the data in 2 table after 7 days of the  last import .this is the code that I have
Delete From TblTemp
date(Day(-7), CurrentStamp).
But for some reason it deleting the data right after it imports it. And it doesn't delete anything out of the other table.
 
Thanks in advance

View 2 Replies View Related

Deleting Frm Multiple Tables At A Time

Jan 10, 2007

I have 3 tables . iwant to delete rows from all the three tables at same time using single statement.All the 3 tables have a unique column which will be supplied ny the user.
DELETE FROM T1,T2,T3 WHERE column1='1'
how do i do it.

View 4 Replies View Related

SQL Server Admin 2014 :: Deleting Job History For Particular Time Period

Feb 8, 2015

How to delete the job history for particular runs.

Suppose if a job run 3 times/day. I want to keep the oldest information and delete the recent 2 runs history.

View 5 Replies View Related

Deleting The Master Table Withour Deleting The Child Tables

Aug 9, 2007

Hi
i have to delete the master table data without deleting the child table records,is there any solution for this,  parent table has relation with the child table.
regards
vinod.t.v

View 9 Replies View Related

How To Convert UTC Time (retrieved From SQL) To Local Time In Reporting Services Based On Time Zone

Aug 7, 2007



Hi all,

I have created a report in SSRS 2005 which is being viewed by users from different Time Zones.

I have a dataset which has a field of type datetime (UTC). Now I would like to display this Date according to the User Time Zone.

For example if the date is August 07, 2007 10:00 AM UTC,

then I would like to display it as August 07, 2007 03:30 PM IST if the user Time Zone is IST.


Similarly for other Time Zones it should display the time accordingly.

Is this possible in SSRS 2005?

Any pointers will be usefull...

Thanks in advance
sudheer racha.

View 5 Replies View Related

Could Not Add The Entry...

Nov 22, 2005

Can someone please help me solve the following error? I am not sure of the version my hosting company is using and where to get the manual.
Could not add the entry because: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-id, title, entry, date_entered) VALUES ('testing', 'testing', . The query was INSERT INTO blog_entries (blog-id, title, entry, date_entered) VALUES ('testing', 'testing', 'testing'.


PHP Code:




if ($dbh = mysql_connect ('localhost', 'blu6592_money', 'rich')) {
    print '<p>Successfully connected to MySQL.</p>';

if (mysql_select_db ('blu6592_myblog')) {
    print '<p>The database has been selected.</p>';
} else {
    die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
}

$query = "INSERT INTO blog_entries
(blog-id, title, entry, date_entered)
VALUES (0, '{$_POST['title']}',
'{$_POST['title']}',
'{$_POST['entry']}', NOW())";

if (mysql_query ($query)) {
    print '<p>The blog entry has been added.</p>';
} else {
    print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

} else {
    die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
}

mysql_close(); 






Thanks in advance.

View 1 Replies View Related

Last Entry In A Log

Aug 13, 2005

(I don't post here often, so in case I'm violating long-standing taboosof this newsgroup, I apologize in advance for calling a relation atable, using nulls, and other ignorant, destructive, and comtemptibleterminology.)I have a table that's keeping a sort of running log of different typesof changes to pieces of data. The table has a foreign key of the databeing changed, the foreign key for the type of change occuring, someinformation about the change in a couple more columns, and a timestampfor each entry. So it's:dataIDeventIDeventInfotimestampWhat I'd like to do, if at all possible, is a single SQL query that,given a dataID, returns the most recent eventInfo and timestamp foreach eventID. Is this possible?Many thanks.-Eric

View 3 Replies View Related

Advice On Entry In To IT

Apr 12, 2004

Anyone Got any other advice?

http://www.dbforums.com/t993214.html

View 3 Replies View Related

Anyone Know What Causes This Error Log Entry?

May 30, 2007

"High priority system task thread: Operating system error Exception 0xAE encountered."

we are seeing this on one of our development servers, running SQL 2005 Enterprise SP1. The symptom is that after the sql service has been running a while (order of days), this error starts getting written to the sql server log file over and over, and eventually the logfile fills the drive.

Apparently it's fixed by this hotfix, but our ops team doesn't want to install this - they'd rather just cycle the service and delete the log when it happens.

I was wondering if anyone else has seen it might know the root cause so we might be able to workaround it without cycling the service. I know, lame question. The correct answer is "install the hotfix" or "install sp2" but our ops team won't do that for now...

www.elsasoft.org

View 2 Replies View Related

Duplicate Entry

Jul 24, 2007

Hi All,

I have a table with name C1_Subscribers with three fields (1)-MobileNumber [varchar]
(2)-ReceivedTime [datetime]
(3)-Status [char].
Now here how to remove duplicate entry of same mobile number to MobileNumber field?

Regards
Shaji

View 4 Replies View Related

Selecting First Entry In Results By Name

Nov 28, 2006

Hello,
I have a table of names/dates as such:
Class 1     1/1/2007Class 1     1/3/2007Class 1     1/5/2007Class 2     2/1/2007Class 2     2/3/2007Class 3     3/1/2007
What I want to do is select only the nearest entry from the list for each distinct class, so the results are like this:
Class 1     1/1/2007Class 2     2/1/2007Class 3    3/1/2007
So basically, I want the first upcoming class in the list for each distinct class name.  How do I do this?  I'm using SQL 2005 Express.
Thanks.

View 3 Replies View Related

Verifying Entry Is Not In DB B4 Inserting

Jun 4, 2007

How do i do that... in sch lab, the lecturer said:    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Try            SqlDataSource2.SelectParameters("Title").DefaultValue = txtProductTitle.Text            GridView1.DataBind()            If GridView1.Rows.Count > 0 Then //if no repeated                 Label1.Text = "Existing Record Found. Please enter another Software."            Else                'SqlDataSource1.Insert()                'Label1.Text = txtProductTitle.Text & " successfully added to the database."            End If        Catch ex As Exception            Label1.ForeColor = Drawing.Color.Red            Label1.Text = "An error occured!" & ControlChars.NewLine & ControlChars.NewLine & _            ex.Message.ToString()        End Try    End Sub but its not working for me... the GridView1.Rows.Count is always 0, if there is a repeat, it should be > 0 

View 4 Replies View Related

DateTime From Database Entry

Nov 9, 2007

Hi, I know this is probably very simple but I am pretty new to this and have tried looking but cant seem to get the search criteria right. I have  a database with a storeDate field which is of shortdatetime type. I am connecting to the database (MSSQL)  via a stored procedure and returning all the records. I then use the code   foreach (DataRow dr in ds.Tables[0].Rows)  {      DateTime dtTo = DateTime.Now;      DateTime dtFrom = DateTime.Parse(dr["storeDate"].ToString());      TimeSpan diff = dtTo.Subtract(dtFrom);  } I am basically trying to find out the age of the database entry by subtracting it from the current DateTime so i can delete records over a certain age. The problem (at least one of them!) is retrieving the "storeDate" object from the database and storing it in the dtFrom object. I have tried just assigning it directly as dtFrom = dr["storeDate"] and various other methods but I just don't know enough to assign it!  Can anyone help me with this or spot any other mistakes in this process of removing old files automatically. Greatly Appreciated,Sean.  

View 4 Replies View Related

Automatic Field Entry

Nov 17, 2007

Hi,I'm creating a database using SQL Server 2005 Express Edition (Comes with Visual Web Developer). The table which I am creating has the following Fields - all don't allow nulls:IDUserIdDateDescription(UserId is a foreign key to asp_net_Users as I am supporting user accounts)Basically what I need to do is create a page where I as an Administrator can log onto and enter just the text for the field Description. Then once I upload this I wish all users to visit the site and view this Description on a page however with it also listing the Administrator who wrote it along with the Date. I wish both of these fields to be added automatically (UserId to display the User Name and the Date to display the date and time with which the Description was added - However these need to be editable by the Administrator if he/she wishes to change them).Can anyone point me in the right direction on the steps needed to create this scenario?Thanks for any helpDaniel    

View 4 Replies View Related

Identical Database Entry Already?

Aug 14, 2005

Here's some code that says it should identify if a user already exists in my database. I have changed the code to match my database, but it seems to have somewhat the opposite affect, rejecting all names (even new ones) or accepting all names (including existing ones). The switch in situations occurs in the "if" statement towardsd the end, when I change the sign of objDR.RecordsAffected.  Do you have any idea what could be wrong? Thanks.
Function DoesUserExist(ByVal userName As String) As Boolean
Dim connectionString As String = "server='(local)Netsdk'; trusted_connection=true; Database='AuthorizedUsers'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Users].[UserName] FROM [Users] WHERE ([Users].[UserName] = @UserName)"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
Dim Cmd as New SQLCommand(queryString, sqlConnection)
With Cmd.Parameters
.Add(New SQLParameter("@username", username))
End With

sqlConnection.Open
Dim blHasRows As Boolean
Dim objDR As System.Data.SqlClient.SqlDataReader = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)

if objDR.RecordsAffected > 0 then
blHasRows="True"
else
blHasRows="False"
End If

Return blHasRows

End Function

View 4 Replies View Related

Select Newest Entry

Feb 22, 2006

How can I select from a table the newest entry.I'm inserting in a table user info and then want to get the users id number

View 9 Replies View Related

How To Prevent Doublicate Name Entry

Feb 23, 2001

hi I have a table I need to have a process which prevent a user from entering a name value( company Name ) in a field. how can I do that .

Ahmed

View 2 Replies View Related

Select Last Entry Per Category?

Nov 8, 2005

Hello,

I am trying to select the last entry (by date) for each category in a table.

For example, if my table had the following fields;

id, category, product, datePosted,....

...how would I select the last product for each category posted by date?

Any guidance is appreciated.

Thanks,
AC

Probably a simple solution, but can't find it my brain right now!

View 7 Replies View Related

Overwriting Entry In Table

Jan 26, 2005

Task:

To insert entries into a table. The table has a primary key based on a field 'ID'. When inserting into the destination table, I want to make sure that the new entry will overwrite the old entry.

What's the quickest/cleaniest way to do this ?

thanks,
Clayton

View 1 Replies View Related

Number Of Entry Query.

Aug 2, 2006

MSSQL2K
SP4

Howdy all. Im trying to write a query that will track a data modification grouped by employer ID and transaction date. I don't know if Im asking it right so here is what I have, plus my current and desired outputs.

--drop table #foo
create table #foo
(empID int,
transDate datetime,
transType varchar(10))

insert into #foo values(1, '01/01/06 01:01:01','Insert')
insert into #foo values(1, '01/01/06 01:01:02','Update')
insert into #foo values(1, '01/01/06 01:01:03','Delete')
insert into #foo values(2, '01/01/06 01:01:01','Insert')
insert into #foo values(2, '01/01/06 01:01:02','Update')

select f.empID, Change =
(select count(transDate) from #foo f2
where f2.empID = f.empID
group by empID),
f.transDate, f.transType
from #foo f

Current results:

132006-01-01 01:01:01.000Insert
132006-01-01 01:01:02.000Update
132006-01-01 01:01:03.000Delete
222006-01-01 01:01:01.000Insert
222006-01-01 01:01:02.000Update

Desired results:

112006-01-01 01:01:01.000Insert
122006-01-01 01:01:02.000Update
132006-01-01 01:01:03.000Delete
212006-01-01 01:01:01.000Insert
222006-01-01 01:01:02.000Update

TIA, CFR

View 5 Replies View Related

&<Long Text&> Entry

Mar 12, 2008

Hi all,

Newbie here, just wanted to get that out of the way first
and foremost.

Im trying to set up a DB in SQL 2000 that allows me to enter
lots of text into a column.

I read one site where it said to use the NTText datatype with a length
of 16. I did that, but everytime I enter alot of text into that column
I get <Long Text> and I dont know how to output that or even
read it.

Do any of you guys know how to either:

1. get the text out of the <long text> or
2. a better way to store that much data.

Thank you in advance!!!

REZ

View 8 Replies View Related

Can Insert Same Exit Value For Entry

Nov 24, 2011

i have data like...

userid startdate in_out
1 2011-11-20 9.30 1
1 2011-11-20 10.30 0
1 2011-11-20 12.30 0
1 2011-11-20 12.45 1
1 2011-11-20 6.30 0

See 1-Entry 0-exit for 2011-11-20 12.30 is exit but entry time of that exit is missing....

Can i insert same exit value for entry?

View 3 Replies View Related

Could Not Locate Entry In Sysdatabases

Feb 7, 2004

Hey there, could someone please help me!!
I had created a database in sql server but since then installed windows xp pro and now when i go through the microsoft sql server dsn configuration the database is not valid and therefore i cannot change the default database as it says it doesn't exist.
So then when i type in command prompt use 'db' it says it doesn't exist but when i try to create 'db' it says that the database already exists.
I get the error message, could not locate entry in sysdatabases for 'cti' (database name).
When i look in mysql - data - along with master etc there is my cti.mdf and log files??
I'm stuck???
Is it that the files just aren't registering through sql server???
Please help!

View 2 Replies View Related

Get Latest Entry Per Userid

Apr 8, 2008

Hi,

I have the following situation:
I have a table that is log of transactions of useractions. Each time a userstatus changes, a new entry is made into the table.

The table has (currently) about 4 million records, and keeps growing each day with thousands of records. It logs the status of about 150 users (currently active).

What I now want is to get the log-entry from all the distinct users that have a log-entry on the latest day (so current day, 'where TimeStamp > 2008-04-08').



(extremely simplified) Example:
(date is y/m/d)


USERID TIMESTAMP STATUS
----------------------------------------------------
... (thousands and millions of records above)
Ed 2008-04-07 18:00:00 Logged_Out
Jim 2008-04-07 18:30:00 Blabla_Status_5
Jack 2008-04-07 19:00:00 Logged_Out
Jim 2008-04-07 19:30:00 Logged_Out
Jim 2008-04-08 06:00:00 Logged_In (<< notice new day)
Jim 2008-04-08 06:01:00 Blabla-Status_1
Bob 2008-04-08 06:03:00 Logged_In
Fred 2008-04-08 06:05:00 Logged_In
Jim 2008-04-08 06:08:00 Blabla-Status_2
Jack 2008-04-08 06:12:00 Logged_In
Fred 2008-04-08 06:20:00 Blabla_Status_5
Jack 2008-04-08 06:12:00 Logged_Out
Fred 2008-04-08 06:12:00 Blabla_Status_4
Jack 2008-04-08 06:12:00 Logged_In
Jack 2008-04-08 06:12:00 Blabla_Status_7
----------------------------------------------------


The result should be:

USERID TIMESTAMP STATUS
----------------------------------------------------
Jack 2008-04-08 06:12:00 Blabla_Status_7
Fred 2008-04-08 06:12:00 Blabla_Status_4
Jim 2008-04-08 06:08:00 Blabla-Status_2
Bob 2008-04-08 06:03:00 Logged_In
----------------------------------------------------


(How) can this be done in one stored procedure?

View 7 Replies View Related

Best Approach For A Required Entry

May 9, 2008

I have an online store with products and categories. The requirements are: Each product can be in one or more categories; a product must be in at least one category.

To accomplish the first requirement, I have a Product table, Category table, and a many-to-many Product2Category table. (Probably not relevant, but a requirement is the Category table is self-referencing to provide sub-categories.)

My question is for the second requirement that each Product be in at least one category. My assumption would be to add a column to the Product table called "ParentCategoryId", which is a foriegn key of the Category table's identity column.

What would be the best approach to ensure a product is in at least one category?

Thank you.

View 2 Replies View Related

Table Entry Problem

Jun 12, 2008

While i execute the below query ,Entry is put in status_report table.But the same if i put in scheduling (Sql Agent) no entry is made in the table and the message success is shown in "Agent Job Activity".

Purpose of the sp is to transfer data from One Server to Another Server.

But if see in the Destination Tables No entry is made.

CREATE procedure RBI_Control_sp
as
begin
set nocount on

begin try
BEGIN TRANSACTION
insert into fin_wh..Status_report
(
[object_name],
row,
st_date
)
select
'Data Tranfer',
'Inprogress--',
getdate()

--Data Transfer From the Live Server [RamcoFin02(scmdb)] to Dw-Server[Ramcovm392(fin_ods)]
exec fin_ods..RBI_Data_Transfer_sp

--temp table Table population,Fetching data from the fin_ods[erp Table]
exec FIN_wh..RBI_SPExecution_sp

Update fin_wh..Status_report
set row= 'Success',
[error_message] = 'No Error',
end_date= getdate()
where row= 'Inprogress--'

COMMIT TRANSACTION
end try

begin catch
ROLLBACK TRANSACTION

Update fin_wh..Status_report
set row= 'Failure',
end_date= getdate(),
[error_message]= cast(error_number() as varchar) + '***' + error_message()
where row= 'Inprogress--'
end catch

set nocount off
end


Txs in advance

View 3 Replies View Related

Keep Only One Record From Duplicate Entry

Feb 18, 2014

How can i keep only one record from duplicate entry.

Example
COLUMN1COLUMN2COLUMN3COLUMN4
AAA121-12
AAA121-13
AAA121-14

Here i want to keep only the top record and want to delete other 2 rows.

View 4 Replies View Related

Multiple Data Entry

Jan 15, 2006

iam new to MS SQL 7 server...i have two tables in my database say Table1 and Table2 having a comman field--- Name String(30). I want that dual data entry should be made for any single entry. That is if a name is entered in Table1, then same entry should be automatically entered in table2

View 8 Replies View Related







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