I have data that sometimes will be modify. when modify the new data will be insert and the old data still remain inside the database. The same item have their own unique id. So I want to query the data that last modified. How?
If I have a view such as: SELECT T.* FROM T When I add a column to table T the view is not updated to reflect that change. Furthermore, if there are other columns after the * in the view (for example SELECT T.*, GETDATE() as "My Date" FROM T) the last columns will contain incorrect data.
Is there a work around for this? An "auto-recompile when tables are modified" kind of option?
Thanks Nick
PS: This is the script I used for testing:
create table tt ( test1 int primary key, test2 int) go insert into tt (test1, test2) values (1,2) go create view vw_tt as select *, getdate() as "My Date" from tt go select * from vw_tt go create view vw_tt2 as select * from tt go alter table tt add test3 int go select * from vw_tt select * from vw_tt2 select * from tt drop table tt drop view vw_tt drop view vw_tt2
Is anyone aware of a method of determining when a table was last modified or accessed?
Some of our databases have tables that I am sure are not being used and I would like to generate a list of tables that have not been accessed or modified for some period of time.
I looked for a system procedure but didn't see anything that satisfied my need.
Currently I rename suspect tables and wait for someone or some process to gripe, but I don't care for that method for obvious reasons.
in microsoft doc there is written on the topic of BP Extensions with SSD's in SQL Server 2014: only clean pages are written to disk... does this mean data pages that have not been modified yet? or also those data pages that have already been modified, and where log has finished writing and the transaction has been marked as commited??
why are there clean data pages being written to L2 cache to make space for other not modified pages? I mean, shoudnt they be modified first, before letting other unmodified data pages into the Cache? I mean they have still to be modified..that makes no sense to me to page them out and page them in again just for other data pages...
I am unable to the access on table even after providing the SELECT permission on table.
Used Query by me :
Here Test is schema ; Card is table ; User is Satish
To grant select on Table
GRANT SELECT ON TEST.Card TO satish Even after this it is not working, So provided select on schema also. used query : GRANT SELECT ON SCHEMA::TEST TO Satish.
Is there any way for me to return the row that was last entered? If so, how do I go about accomplishing this?
For example,
Column1-Plant NameColumn2-Creation DateColumn3-Comments Bayport 12305/24/01 2:51 AMAirflow became unstable Bayport 12305/24/01 4:00 AM Bayport 12305/24/01 5:36 AMNo events Bayport 12305/24/01 1:00 PM Bayport 12305/26/01 2:45 PMNo events Bayport 12305/26/01 3:12 PMStarted liquifier 25% LIN Bayport 405/24/01 2:51 AMSwung liquifier 0% to LIN Bayport 405/26/01 5:45 AM Bayport 405/26/01 5:15 PMLiquifuer @ 25% LIN Coatesville05/24/01 9:32 AM Coatesville05/26/01 4:25 PMNo events
If I were to query against 5/26, I would want my result to return as: Bayport 123 5/26/01 3:12 PM (because this was the last row entered on the 26th) Started liquifier 25% LIN. Bayport 4 5/26/01 5:15 PM (because this was the last row entered on the 26th) Liquifier @ 35% LIN. Coatesville 5/26/01 4:25 PM No events.
I am taking a "complete backup" of my production db every day using Backupagent of Arcserver 2000. But the Modified Date of .mdf and .ldf files show an older date. Is it normal? Thanks Wilson
Here's an updated version of bigtables.sql that also displays the ratio of index size to data size and the percentage of unused space per table. I've found the index to data ratio particularly helpful for finding and fixing over-indexing.
-- Create a cursor to loop through the user tables declare c_tables cursor for selectid fromsysobjects wherextype = 'U'
open c_tables
fetch next from c_tables into @id
while @@fetch_status = 0 begin
/* Code from sp_spaceused */ insert into #spt_space (objid, reserved) select objid = @id, sum(reserved) from sysindexes where indid in (0, 1, 255) and id = @id
select @pages = sum(dpages) from sysindexes where indid < 2 and id = @id select @pages = @pages + isnull(sum(used), 0) from sysindexes where indid = 255 and id = @id update #spt_space set data = @pages where objid = @id
/* index: sum(used) where indid in (0, 1, 255) - data */ update #spt_space set indexp = (select sum(used) from sysindexes where indid in (0, 1, 255) and id = @id) - data where objid = @id
/* unused: sum(reserved) - sum(used) where indid in (0, 1, 255) */ update #spt_space set unused = reserved - (select sum(used) from sysindexes where indid in (0, 1, 255) and id = @id) where objid = @id
update #spt_space set rows = i.rows from sysindexes i where i.indid < 2 and i.id = @id and objid = @id
Hello,Is there a way in MSSQL server to find all the objects in the databasebased on the modified date rather than the created date.Thanks in advanceKumu
I have stored procedure to show 10 new record from table:SELECT TOP 10 *FROM tableWHERE (id = @id)ORDER BY id DESC and work fine.I'd like to show 10 new record and include modified record as new record. Wo to do that?
Does anyone know how to get a table's 'last modified date' in SQL 7 ? Sysobjects contains the 'create date', but I can't find a 'last modified date' anywhere......
My manager ask me to provide him with the total number of records which have been added, deleted or modified on a certain database in SQL Server 2000 during the month of September. Is there away to get that information from the transaction log or by any how?
if you all add ID's with your Inserts and Modified (Date) fields. Such as 1 would indicate if the record was inserted manually, whereas 2 might indicate it was update or inserted by a web application.
I want to retrieve the values from store_geofence table where the timeduration exceeds certain interval
the procedure is as below CREATE procedure [dbo].[GeofenceByCustomer] @regno nvarchar(50), @frmdate nvarchar(50), @todate nvarchar(50), @Geofence nvarchar(50), @interval int, @userid nvarchar(50) as begin declare @val int Declare @strSql as nvarchar(3000) Select @val=count(*) from basestation where superuserid=@userid and base_station_name=@Geofence
--if(@val=0) begin create table #templ(registrationno nvarchar(50),basestation nvarchar(50),entry_time datetime,exit_time datetime,duration int) select @strSql=' insert into #templ(registrationno,basestation,entry_time,exit_time,duration) select registrationno,basestation,entry_time,exit_time,datediff(mi,entry_time,exit_time) as duration from store_geofence where entry_time>'+@frmdate+' and exit_time<'+@todate+' and datediff(mi,entry_time,exit_time)>'+@interval+' and basestation in ('+@Geofence+') order by entry_time,registrationno' execute (@strSql) print @strSql select * from #templ drop table #templ end
end GO
I should specify the duration in int to take affect
datediff(mi,entry_time,exit_time)>'+@interval+'
but i do not know how to rewrite this path i cannot put as datediff(mi,entry_time,exit_time)>'+@interval+'
it returns an error Syntax error converting the nvarchar value ' insert into #templ(registrationno,basestation,entry_time,exit_time,duration) select registrationno,basestation,entry_time,exit_time,datediff(mi,entry_time,exit_time) as duration from store_geofence where entry_time>01/01/2008 and exit_time<01/01/2008 and datediff(mi,entry_time,exit_time)>' to a column of data type int.
If we want to get the changes happened in database we will get through sys.objects or sys.tables .but we are only getting it table name . But how to get by table name and what the column added to that table or what column has been modified (datatype or constraint) .
For example if i added employee table column called deptid it should be shown in changes in geiven date
SELECT modify_date ,type_desc ,name FROM sys.objects WHERE is_ms_shipped=0 --AND modify_date>='yyyy/mm/dd' <--optionally put in your date here ORDER BY 1 DESC
How to get column name of a table which is modified...
the ssis package loops through a folder using a foreach loop container and imports the data inside each .csv file into the database.
Now I would like to add the functionality to first check the modified date of the .csv file. If it is NOT today's date then the package should fail or go to error.
Hi, the ssis package loops through a folder using a foreach loop container and imports the data inside each .csv file into the database. Now I would like to add the functionality to first check the modified date of the .csv file. If it is NOT today's date then the package should fail or go to error. Any thoughts how to do this please? Thanks
I was just thinking about a situation which I have been tasked with in that I have a package that is scheduled to run once a day which will import data from a flat file. The data does not have any distinguishing time that can be used to see whether or not it is beyond a last imported time.
I was wondering, is there a way to access the date modified of the file? If so I could simply append this time to a table which keeps track of all of the files and the modified dates which I have ever imported for this task.
I have store procedure that was created on 9/15/2005. It went through some modificiations since then. How can I find out when was the last updated or last two update on this object?
I have a simple SQL2005 database with a single table that I need to be able stamp a record in a "modifiedon" field to represent when it was modified. It's set to a datetime format, but am unsure how to proceed next.
I am looking for two sql scripts,1. How can i check when a tables structure was last modified? 2. How can i find the structure differences between two databases that were created the same but changed over time individualy?Looking for sql scripts to do this. Any help on either would be great.Thanks