How can I get the modified table name(any table in db) and it's modified value without using triggers in SQL Server? - sql

I am creating database snapshot for reporting(creating a common demoralized table from normalized tables), for which I need to enter normalized tables modified values at the same time when the table modify. I want a common solution for this. Same is achievable using triggers but I am looking for some other generic solution which will work with any table change. Is there any other way in SQL server by which I can achieve the same?

Related

SQL Server 2016: Replicating tables generated by sp_help

I am in the process of writing a relatively large query which organizes a bunch of information on tables in my database. One thing I want to add is information on indexes and constraints on each table.
I found that sp_help 'tablename' generated two tables with basically exactly what I wanted, specifically the constraint and index tables, organized in an ideal way (all applicable keys grouped together as one bit of text, separated by commas).
Is there any simple way to either command sp_help to only pull these tables for easy access, or barring that any way to replicate the exact form of these tables with a SQL query?
It seems possible to brute force a replica of these tables without too much difficulty using a clunky mixture of sys and information_schema, but is there any minimal/elegant way to do it?
Try reading through the following blog post by Kimberly Tripp -
https://www.sqlskills.com/blogs/kimberly/sp_helpindex-v20170228/
You can download a procedure called [sp_SQLskills_helpindex], to be run as per the below -
sp_SQLskills_helpindex [TableName]
The result set can be stored in a temp table and used in whichever way you wish.

Adding transformations in Sybase replication server

We have primary source database as Oracle 11gR2 and target as SAP HANA. We are trying to test SAP - Sybase Replication server for replication from Primary ORACLE to Target HANA.
We need to add extra columns such as RECORD_DATE and LAST_MODIFIED_DATE to HANA tables. Is it possible to add Transformations or extra columns to target tables which are not present in Primary Database.
Best Regards
are you thinking of adding these fields during replication.
or want to merge them after replication. If after replication you want to merge them simply just go to Hana Studio and make an Information view to get the the merged or simply joined data from different tables.
and if that table is not present in the the source System then instead of replication make a Excel flat file and import it into Hana using the Import option on the RHS of hana studio.
and The only way to Alter a table definition in Hana is by Using the Alter Table SQL statement no other Shortcuts. Or just import and make a join.
I'm assuming you want to capture auditing data for records inserted/updated by the Repserver maintenance user (in the HANA database).
While the column default (for inserts; as discussed with Shivam) will work, for updates you've got a few options:
an update trigger on the HANA table [I don't work with HANA so I don't know if this is doable]
defining the update column as a (materialized) computed column, with the associated function being responsible for obtaining the current date/time when other columns in the table are modified [while this is doable in Sybase ASE, I don't know if this is doable in HANA]
(in repserver) create a custom function string for the rs_update function on this table which emulates a standard rs_update function string with the addition of an update of LAST_MODIFIED_DATE = getdate() (replace getdate() with HANA's equivalent of the current date/time) [there are a couple different ways to do this depending on SRS version, what's doable with HANA-specific function strings, and personal preference - a bit much to go into at this point if a custom function string is going to be out of the question or you've already got an acceptable solution]

Best way for block SQL table records in SQL Server

I have SQL Table in SQL Server like this:
In this table there are old records (Last year).
I should use this table again.But old records to be blocked (No operation taken on them (Select,Update, Delete)).
I can't modify design table and add another field like locked or date or add new table for handle operations.
Is this possible in SQL Server?
It would be very helpful if someone could explain best solution for this problem.
Thanks.

Is possible determine value of column using a query to another table with stored procedures?

I'm working in a project where I need to make changes in the database to create a history of managers and status of projects and use it, instead of the already existing columns of managers and status in a projects table. The problem is: there are several aplications that may or may not be using those fields in this old table and would be almost impossible find all the aplications that use those fields to make them use the new tables.
So, I had been thinking, there is any way to create a stored procedure in a db2 database that can make the values in the manager and status columns in the projects table come from a query to the new history tables?
Sorry for my bad english.

SQL Server: Create a duplicate of a database without the data

I have a database called AQOA_Core with huge amount of data.
I have a newly created database called AQOA_Core1 which is basically empty. I want to write a query to duplicate AQOA_Core to AQOA_Core1 without the data. I guess to be precise I want to create a skeleton of the primary database into the secondary database.
PS: I use Toad for my database operations.
You can use SQL Server Script Wizard for scripting database objects. You can exclude data, and select the database object types you want to include in your script
Please check the SQL Server guide I referenced above,
I hope it helps you