I need some help in order to reduce the amount of code needed to
implement the logging of INSERT and UPDATE in my application's
database.
In every table of my database I have four fields (CreatedBy,
CreatedTime, ModifiedBy, ModificatedTime), these fields allow me to
trace the users who create and modify the registers in my application.
I know that I can add in every stored procedure a piece of code who
uses the app user as a parameter, and insert these information in the
register. But I would like to go beyond these method. I imagine there
is a better way of doing it, and I don't like to use triggers. Is
there any method, within the SQLServer functionality, that allows me
to automate this process?
So, any help would be very appreciated!!
Thank you very much in advance!
I'm wondering if there is a control available for creating/modifying db tables through a web interface. I want for users to be able to add/remove, rename, and change the datatype of certain fields in a database table. I've been searching all day online if such a control exists in asp.net but haven't found anything.
I'm trying to create an SSIS package that will do a straight data copy between databases. The problem is that the underlying schema of the origin may change and the requirement is that the transfer be table driven. i.e. the tables that are copied are listed in a table and there should be no human intervention when the schema changes.
I'm moving data between SQL Server and SQL Azure, so backup and restore doesn't work. Has to be an SSIS package.
What's the best way to deal with a changing schema in an SSIS package? Can I delete and rewrite the underlying XML for any tables that change? Do I need to do it programmatically with C#? Do I need to create the package from scratch each time?
Is there a way in SQL Server 2005 to insert a unique row, and that the primary key column (which is an int typed) will get an index number ? I want this in order to avoid code behind logic.
I mean something like incrementing from last index if all lower numbers are already present, or retrieving the "holed" index ...
I am trying to migrate a system across and need some help tidying data and merging info. Firstly if I have some companies with the suffix 'Limited' and some with 'Ltd' ie BBC Ltd and BBC Limited. How do I change all these to read the company name and then Ltd?? Secondly I am pulling info from a table which has company name duplicates into a table that also may have company details relating to that company name. I wish to add the details if the company name doesn't exist in the table and also only input the once from the source table. I am using cursors for this. My scripts see below is adding every record. Any ideas why?? Thanks for any suggestions
CREATE PROCEDURE check_company2 AS declare @id varchar(50), @company_name varchar(50), @business_type varchar(50), @hardware varchar(50), @operating_system varchar(50), @networks varchar(50), @pcs varchar(50), @terminals varchar(50), @test_companies_id varchar(50) begin declare s_completelist_cur cursor for select [company name],[business type],[hardware],[operating system],[networks], [pcs],[terminals] from s_completelist open s_completelist_cur
fetch next from s_completelist_cur into @company_name, @business_type, @hardware, @operating_system, @networks,@pcs, @terminals while (@@fetch_status=0)
begin print @company_name select @test_companies_id from companydetails c where c.company_name = @company_name if @test_companies_id is not null
begin print 'match found' end else begin insert into companydetails ( company_name, business_type,hardware, op_system, network, pcs, terminals) values (@company_name, @business_type,@hardware, @operating_system, @networks, @pcs, @terminals) end
fetch next from s_completelist_cur into @company_name, @business_type, @hardware, @operating_system, @networks,@pcs, @terminals end close s_completelist_cur deallocate s_completelist_cur end
I have a series of DTS packages. Each package has 20 queries. Each query has a server name. Is there a way to change the servername without editing each query in each DTS package. I'd like to copy the template DTS package, then perform the modification.
Im trying to basically take an email address user@domain.com that is in a row and basically split it up or get 1 side.
Im trying to find the command if it exists or a way to do this in tran sql to basically give me everything left or right of the '@' symbol, is there an easy way of doing this? Thanks!
I have converted Access database to sql express. Access Database had AutoNumber FIelds for which trigger was generated by Upsizing wizard.
Now when I import data from client the autonumber field value changes because trigger is fired which distroys all links
I want to modify trigger so that it generates new number only when it is not supplied in a insert command.
Please help. Code is given below. Also suggest how to save because when I use save, it asks for a new .sql file name and a new file is generated instead of modifying the same trigger
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER TRIGGER [dbo].[T_AcControlLimit_ITrig] ON [dbo].[AcControlLimit] FOR INSERT AS SET NOCOUNT ON DECLARE @randc int, @newc int /* FOR AUTONUMBER-EMULATION CODE */ /* * RANDOM AUTONUMBER EMULATION CODE FOR FIELD 'IntAcControlCode' */ SELECT @randc = (SELECT convert(int, rand() * power(2, 30))) SELECT @newc = (SELECT IntAcControlCode FROM inserted) UPDATE AcControlLimit SET IntAcControlCode = @randc WHERE IntAcControlCode = @newc
I have binded a DataGradView (DGV) with a Dataset (DS) , i execute and modify on the DataGradView the primary key (IDObj) and also the two other columns, by clicking on the UpDate button i call the function UpDateTable :
public void UpdateTable(string nameTable) { // con : ma connection OLE Ã un fichier Access 2003 // DS : dataSet // DAdp : Dataadapter // nameTable : nom de ma table
OleDbCommand comdUPDATE;
string CommandText = "UPDATE " + nameTable + " SET IDObj=@IDObj ,NameParent=@NameParent,TypeObj=@TypeObj WHERE IDObj=@IDObj";
comdUPDATE=DAdp.UpdateCommand = new OleDbCommand(CommandText, con);
We have an SSAS instance where when we run the query "select * from $system.discover_traces" the creation time in the resultset shows a different time from when we actually started the trace.
for example if we have create the trace at 3.30pm it shows 7.35 pm in the Sql server management studio resultset when we run the query "select * from $system.discover_traces".
My problem is related to database and data. I building a project in ASP.NET 2.0 with the help of VWD in which i have certain records and each record has a unique id with it.Now my problem is that when a user wants to edit a certain record i want the user to enter a record id for that record. Now if the record id matches any record in the database then that record should be dislayed in another page with and edit option with it.
I have listed a view below and a portion of the result set that is returned when I run the code in Query Analyzer. This is part of a timesheet application that logs hours per SCHLSTUID per SECTIONID per week. This returns the SCHLSTUID(user's ID), SECTIONID, Date that the week starts, the first date that time was logged. The user could be in several SECTIONID's for the same week. I need to modify this so that it returns the date that the first time was logged for any of the SECTIONID's per week. I know that this is probably something simple that I'm overlooking but I just can't get it to work correctly.Example: SCHLSTUID SECTIONID ATTSTARTDT FirstTimeEnteredDOn601868445 EN4AR001 2005-09-18 20:59:21.120 2005-09-19 20:59:21.120601868445 MAA1R001 2005-09-18 20:59:21.120 2005-09-18 20:59:21.120This would need to return 2005-09-18 20:59:21.120------------------------------------------------------------------------------------------------------601868445 EN4AR001 2005-10-02 20:59:37.427 2005-10-02 20:59:37.427601868445 MAA1R001 2005-10-02 20:59:37.427 2005-10-02 20:59:37.427This would need to return either 2005-10-02 20:59:37.427------------------------------------------------------------------------------------------------------601868445 EN4AR001 2005-10-09 20:59:37.823 2005-10-09 20:59:37.823601868445 MAA1R001 2005-10-09 20:59:37.823 2005-10-13 20:59:37.823This would need to return 2005-10-09 20:59:37.823----------------------------------------------------------------------------------------------------------------------------------------------------CREATE VIEW dbo.vExportStartWeekASSELECT TOP 100 PERCENT schlstuid, sectionid, ATTSTARTDT, MIN(TimesheetDate) AS FirstTimeEnteredOnFROM (SELECT schlstuid, sectionid, ATTSTARTDT, ATTSTARTDT AS TimesheetDate, sunmns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, ATTSTARTDT AS TimesheetDate, sunhrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 1, ATTSTARTDT) AS TimesheetDate, monmns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 1, ATTSTARTDT) AS TimesheetDate, monhrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 2, ATTSTARTDT) AS TimesheetDate, tuemns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 2, ATTSTARTDT) AS TimesheetDate, tuehrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 3, ATTSTARTDT) AS TimesheetDate, wedmns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 3, ATTSTARTDT) AS TimesheetDate, wedhrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 4, ATTSTARTDT) AS TimesheetDate, Thrmns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 4, ATTSTARTDT) AS TimesheetDate, Thrhrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 5, ATTSTARTDT) AS TimesheetDate, Frimns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 5, ATTSTARTDT) AS TimesheetDate, Frihrs AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 6, ATTSTARTDT) AS TimesheetDate, Satmns AS TimeEntered FROM TimeSheetDailyAttendance UNION ALL SELECT schlstuid, sectionid, ATTSTARTDT, DATEADD(d, 6, ATTSTARTDT) AS TimesheetDate, Sathrs AS TimeEntered FROM TimeSheetDailyAttendance) TimesheetDatesWHERE (TimeEntered <> 0)GROUP BY schlstuid, sectionid, ATTSTARTDTORDER BY schlstuid----------------------------------------------------------------------------------------------------------------------------------------------------This is a portion of what is returned:SCHLSTUID SECTIONID ATTSTARTDT FirstTimeEnteredDOn601868445 EN4AR001 2005-09-18 20:59:21.120 2005-09-19 20:59:21.120601868445 MAA1R001 2005-09-18 20:59:21.120 2005-09-18 20:59:21.120601868445 EN4AR001 2005-09-25 20:59:36.670 2005-09-25 20:59:36.670601868445 EN4AR001 2005-10-02 20:59:37.427 2005-10-02 20:59:37.427601868445 MAA1R001 2005-10-02 20:59:37.427 2005-10-02 20:59:37.427601868445 EN4AR001 2005-10-09 20:59:37.823 2005-10-09 20:59:37.823601868445 MAA1R001 2005-10-09 20:59:37.823 2005-10-13 20:59:37.823----------------------------------------------------------------------------------------------------------------------------------------------------Thank you for any help that you can give me.Scott
Hello ;Can any one point me how to trace any modification made on a certain tabeles with in any data base?what i mean is if i have table "a" and i add updated some rows with it ... is there a way to figure iut the old data and the new data?simply i can create another table "history_on_a" which will be filled by a trigger when any updates happen ...this solution will consume my hard disk so is ther a built in funtion with sql ?so if any one can tell me what to search for or any idea
Is there a way to find out when the last modification or change to data in a table occured ? How about the last change of a view ?
We'd like to be able to extract data to another table based on a view. Then, at a later date, check to see if the first table or view has changed since the last extract. If not, then we don't need to re-extract the data, we know it hasn't changed.
We having the SQL SERVER 2000 Production server. We need to cofigure the alert on the production server that if any objects schema or SP got changed then server should fire the alert to all of DBA mailid.
I'm wondering about datetimes modification while debugging. I've a backup of a db debugging searching for some answeres. Problem is I have to asume it's one month back in time, so when I get the value from some date functions, if I after that modify the date value displayed for the parameters (debugging with vs pro 2005) will it be my modified values that it uses when those variables are used? It seams like it, but I'd like to be 100% sure.
Hi,I'm writing an application that involves data that has a set of usersthat are allowed to perform certain operations on it.i.e. Only the row owner can modify a row, but there is a set of userswho can view it.At the moment, I've started to implement this by calling a UDF at thebeginning of each stored procedure that validates that the user isallowed to call the procedure on that particular row (trusting a higherteir to verify the user), and throws an error if they are not.I don't particularly like this solution, as I need a UDF for eachprocedure, and will have to re-write the udf's if the access ruleschange (which they might).Can anyone suggest a method of implementing a more generic rowpermissions system?Cheers,Ben
This is the best suited forum I found that fits my problem. If there's a better one, please direct me to it.
I have an Access database that contains (for the purpose of my application) a lot of information (15,000+ records in one of the tables). My application suffers from slow performance because of the size of the tables (this is because the data has to be compared to data on a Palm device). I have done a lot of optimizations to the code, but I haven't found a way to implement the best optimization for my case: Getting row- and field-level modification dates. That way I can only compare relevant data and not the whole database.
For example, I wish there was a way to filter out rows from a table that were modified before January 1st, 2007. Another example: Filter out rows that their Address column was modified in the last two weeks.
I know that a partial solution will be to implement this on my own: adding a Modified column to all my tables. But, as I said, this is only a partial solution because it saves only the row's modification date, and not for each of the fields. Plus, this is a really ugly solution, having this column standing out everywhere.
Is there a chance this is implemented inside Access (or SQL server, for that matter)? The closest I came was finding out that there's a field in msysobjects that specifies when a table was last modified. But not a row or a field in a row.
Any help will be greatly appreciated!
Thanks.
P.S. The weird thing is that this "modified" bit that I'm looking for is implemented on Palm devices and is very easy to use... Seems ironic that there won't be a simple way to do this on a PC.
P.P.S. I guess row- and field-level modification dates are the same... of course, Modified(row) = MAX(Modified(field1), Modified(field2), ...)
(This was previously posted @ http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1935938&SiteID=1&mode=1, I transferred it here because it's more relevant)
I have an Access database that contains (for the purpose of my application) a lot of information (15,000+ records in one of the tables). I use C++ non-.NET ADO in order to access that database (msado15.dll). My application suffers from slow performance because of the size of the tables (this is because the data has to be compared to data on a Palm device). I have done a lot of optimizations to the code, but I haven't found a way to implement the best optimization for my case: Getting row- and field-level modification dates. That way I can only compare relevant data and not the whole database.
For example, I wish there was a way to filter out rows from a table that were modified before January 1st, 2007. Another example: Filter out rows that their Address column was modified in the last two weeks.
I know that a partial solution will be to implement this on my own: adding a Modified column to all my tables. But, as I said, this is only a partial solution because it saves only the row's modification date, and not for each of the fields. Plus, this is a really ugly solution, having this column standing out everywhere.
Is there a chance this is implemented inside Access (or SQL server, for that matter)? The closest I came was finding out that there's a field in msysobjects that specifies when a table was last modified. But not a row or a field in a row.
Any help will be greatly appreciated!
Thanks.
P.S. The weird thing is that this "modified" bit that I'm looking for is implemented on Palm devices and is very easy to use... Seems ironic that there won't be a simple way to do this on a PC.
P.P.S. I guess row- and field-level modification dates are the same... of course, Modified(row) = MAX(Modified(field1), Modified(field2), ...)
My idea is to read in source and destination values from a table and using these values within a ForEach loop dynamically alter the source, destination and mapping on the data flow within the package. My reading on SSIS leads me to believe that these properties are not available for modification at run-time. Has anyone any ideas on how to accomplish this task. I have data in over 200 tables to import every 4 hours so I'd rather have to maintain 1 package rather than 200.
I used to rely heavily on the sysobjects.crdate under mssql 6.5 to identify the last time an object was updated (primarily sprocs, but also tables and views). With the Sql7 Alter command, there doesn't seem to be any easy way to tell the last time an object was changed. Is this data stored out on any of the system tables/information views?
I would like to know about the DML process (Insert/update /delete) in a particular table .. it is like change tracking but I also want to know the modification date
I know CDC ( Change data capture ) but unfortunately it needs SQL 2008 developer/enterprise edition and my SQL server is SQL 2008 STANDARD edition.
I have read that I need to add an instead of trigger. I have no idea how to do this. I am basicaly trying to update at the moment but will also need to insert later. From the code in VWD2008 I only get the error when i include this info here: When i press update and these below are included in the update statement then i get the error. [S_DATE] = @S_DATE, [END[IS_CONFIRMED] = @IS_CONFIRMED, [IS_PAID] = @IS_PAID, [S_Descript] = @S_DESCRIPT[COMPANY] = @COMPANY[MONTH] = @MONTH[ACCOUNT] = @ACCOUNT
Here is view from SQL 2000. CREATE VIEW dbo.VIEW_TRAINING AS SELECT dbo.ADDRESS.EMAIL, dbo.ADDRESS.FIRST_NAME AS [first name], dbo.ADDRESS.LAST_NAME AS [last name], dbo.ADDRESS.STATE, dbo.ADDRESS.TEL1 AS phone, dbo.CUST.NAME AS Company, dbo.ITEMS.DESCRIPT AS S_Descript, dbo.ADDRESS.JOB_TITLE AS Job_Title, dbo.TRAINING_SCHEDULE.[MONTH], dbo.TRAINING_SCHEDULE.S_DATE, dbo.TRAINING_SCHEDULE.END_DATE, dbo.TRAINING_SCHEDULE.IS_CONFIRMED, dbo.TRAINING_SCHEDULE.IS_PAID, dbo.TRAINING_SCHEDULE.CUST_CODE AS Account, dbo.TRAINING_SCHEDULE.SCHEDULE_ID
FROM dbo.TRAINING_SCHEDULE INNER JOIN dbo.CUST ON dbo.TRAINING_SCHEDULE.CUST_CODE = dbo.CUST.CUST_CODE RIGHT OUTER JOIN dbo.X_INVOIC RIGHT OUTER JOIN dbo.INVOICES ON dbo.X_INVOIC.ORDER_NO = dbo.INVOICES.DOC_NO LEFT OUTER JOIN dbo.ADDRESS ON dbo.INVOICES.CUST_CODE = dbo.ADDRESS.CUST_CODE LEFT OUTER JOIN dbo.ITEMS ON dbo.ITEMS.ITEMNO = dbo.X_INVOIC.ITEM_CODE ON dbo.CUST.CUST_CODE = dbo.ADDRESS.CUST_CODE
WHERE (dbo.X_INVOIC.ITEM_CODE LIKE 'FOT-%') AND (dbo.X_INVOIC.STATUS = 7) AND (dbo.ADDRESS.TYPE IN (4, 5, 6)) AND (dbo.ADDRESS.EMAIL <> '') AND (dbo.ADDRESS.COUNTRY = 'UNITED STATES') AND (dbo.ITEMS.CATEGORY = 'TRAININGCLASSES') AND (dbo.TRAINING_SCHEDULE.CUST_CODE = 'steve')
Here is the forms code I am working with: used VWD to generate the forms...I added update...<%@ Page Language="C#" AutoEventWireup="true" CodeFile="training.aspx.cs" Inherits="training" TRACE = TRUE%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
We are currently using 2008 environment. We do have an SSIS Package running. The package used to run everyday and take the production server full backups and restore into the another server. Then do some delete commands and do some updates in that database on that server (We have some sensitive data other than Production we have to run that scripts in any environment). After run all those delete statements another team will read the data from that database.
We are planning to migrate to 2014 and set up always on and use the replica as the source. In this case how the package will work?
How to change that SSIS package. With the 2014 always on we are directly reading the data there is no backups to restore then how to run the delete statements?
View or function 'MutualFund' is not updatable because the modification affects multiple base tables.
I get the above error when i try to delete rows from a view. i tried the following code with a table. it works perfectly. i want the same behaviour for a view. can anyone help.
Delete MutualFund from MutualFund inner join MutualFund_history on MutualFund.SecurityID= MutualFund_history.SecurityIDwhere MutualFund.MorningstarCategoryID=MutualFund_history.MorningstarCategoryID and MutualFund.MorningstarAssetClassID= MutualFund_history.MorningstarAssetClassID and MutualFund_history.insertdt =(Select MAX(DsegLastUpdated) from Timestamp_History(nolock))
"MutualFund" is a view. if it were a table, the above works well. but how can i simulate the same effect for a view. any help will be greatly appreciated.
managed plug-in framework that's available for download here: http://www.microsoft.com/downloads/details.aspx?familyid=DF0BA5AA-B4BD-4705-AA0A-B477BA72A9CB&displaylang=en#DMAPI.
This package includes the source code for a sample plug-in algorithm written in C#.
in this source code all .cs files are modified for clustering algorithm
if my plugin algorithm is of association or classification type then what modifications are requried in source code???