How can I replicate between two tables with different names? - sql-server

While setting up the database replication, the destination table that is getting created is having the same schema name of the source table. I want to have a different destination schema. But how do i get it?

Your question is addressed directly in this forum post.
Snippet:
...change destination_table to the new
table name in sp_addarticle, or in the
wizard, when you get to article
dialog, highlight the table, click the
Article Properties drop down, and
select set properties of highlighted
table article, and in the destination
object name enter the name of the
article.

Related

How to determine a table's dependencies?

I need to migrate some data between environments. The data structures are going to be exactly the same, however some of the data is ID dependent on existing data which will have to be adapted, or more precisely, userIds (such as ownership, last modification, etc).
I have already established as a requirement that usernames on both environments will always refer to the same user, so what I need to do is to determine which columns reference the user table, and transform my data from one environment to the other.
I have tried checking the SQL Server Management Studio's Object dependencies on the user table, and got a detailed list of which objects are referencing the ID column. However, there is at least one table that i know that does refer the ID column that does not appear in the list.
Constraint Options on Table
Dependants on the user table
Attempting to update a row from the proposal table with an unexisting id displays the expected exception:
Msg 547, Level 16, State 0, Line 1
The UPDATE statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_tpt_PROPOSAL_OSUSR_A7L_USER_MASTER_CREATEDBY". The conflict occurred in database "databasename", table "dbo.OSUSR_A7L_USER_MASTER", column 'ID'.
Can there be any reason for this table to not appear as a dependent on the user's table? Is there a way to determine if there are more tables that are not being displayed?
Try this may be it will helpful for you.
EXEC sp_fkeys 'TableName'
You can follow the following procedure, in Object Explorer, expand Databases, expand a database, and then expand Tables.
Right-click a table, and then click View Dependencies.
In the Object Dependencies dialog box, select either Objects that depend on , or Objects on whichdepends.
Select an object in the Dependencies grid. The type of object (such as "Trigger" or "Stored Procedure"), appears in the Type box.
Also, this link is very helpful: https://learn.microsoft.com/en-us/sql/relational-databases/tables/view-the-dependencies-of-a-table?view=sql-server-2017
You can use also this command:
USE [databasename]
GO
EXEC sp_depends #objname = 'objectname';

How to add table for database in lightswitch server

I have to add a table for database in Light-switch server, when i click the add table, i can able to add only the fields name and its property in the table. How can i add values for the field? I have to add values for the Name and Order fields of a table. Can any one help me.
Thanks in advance
Click to highlight the field you want to edit, and look for the Properties window. In properties, you should see Choice List, as long as you are looking at the Server perspective, and you are not looking at a Primary Key.

Trying to find name of TFS DB Table containing custom field data

I have a quick question, what is the name of the TFS 2010 database table that contains values for any custom fields.
I did a query against the TFS_Warehouse DB and the dbo.DimWorkItem table. However, I cannot find any of my custom work item fields under this table.
Can someone point me to the correct TFS 2010 table containing the custom field data? When I worked with Quality Center, the tables were pretty well defined so it was easy to do backend DB queries. TFS does not seem that intuitive.
Thanks
you have to add "reportable" to field definition.
Example - FIELD name="Scope" refname="xxx.Scope" type="String" reportable="dimension"
Wait few minutes and you'll see field in warehouse DB
look,
you need to go to your collection database, and to check a table called something like Fields.
there, you will find the new field properties and the type as well.
you can change the type to string and to be reportable.
go to the table of the WORKITEMLATEST, and check the field- you can see the name of the field like what was mentioned in the FIELDS table,.
open your work item normally, edit that field information, click save...
you can see your data updated in the WORKITEMLATEST table
BUT...
the problem is the STRING type is limited... I tried to add more text.. it keep telling me that number of character is over limit !

inserting into a view in SQL server

I have a SQL Server as backend and use ms access as frontend.
I have two tables (persons and managers), manager is derived from persons (a 1:1 relation), thus i created a view managersFull which is basically a:
SELECT *
FROM `managers` `m`
INNER JOIN `persons` `p`
ON `m`.`id` = `p`.`id`
id in persons is autoincrementing and the primary key, id in managers is the primary key and a foreign key, referencing persons.id
now i want to be able to insert a new dataset with a form in ms access, but i can’t get it to work. no error message, no status line, nothing. the new rows aren’t inserted, and i have to press escape to cancel my changes to get back to design view in ms access.
i’m talking about a managers form and i want to be able to enter manager AND person information at the same time in a single form
my question is now: is it possible what i want to do here? if not, is there a “simple” workaround using after insert triggers or some lines of vba code?
thanks in advance
The problem is that your view is across several tables. If you access multiple tables you could update or insert in only one of them.
Please also check the MSDN for more detailed information on restrictions and on proper strategies for view updates
Assuming ODBC, some things to consider:
make sure you have a timestamp field in the person table, and that it is returned in your managers view. You also probably need the real PK of the person table in the manager view (I'm assuming your view takes the FK used for the self-join and aliases it as the ID field -- I wouldn't do that myself, as it is confusing. Instead, I'd use the real foreign key name in the managers view, and let the PK stand on its own with its real name).
try the Jet/ACE-specific DISTINCTROW predicate in your recordsource. With Jet/ACE back ends, this often makes it possible to insert into both tables when it's otherwise impossible. I don't know for certain if Jet will be smart enough to tell SQL Server to do the right thing, though.
if neither of those things works, change your form to use a recordsource based on your person table, and use a combo box based on the managers view as the control with which you edit the record to relate the person to a manager.
Ilya Kochetov pointed out that you can only update one table, but the work-around would be to apply the updates to the fields on one table and then the other. This solution assumes that the only access you have to these two tables is through this view and that you are not allowed to create a stored procedure to take care of this.
To model and maintain two related tables in access you don’t use a query or view that is a join of both tables. What you do is use a main form, and drop in a sub-form that is based on the child table. If the link master and child setting in the sub-form is set correctly, then you not need to write any code and access will insert the person’s id in the link field.
So, don’t use a joined table here. Simply use a form + sub-form setup and you be able to edit and maintain the data and the data in the related child table.
This means you base the form on the table, and not a view. And you base the sub-form on the child table. So, don't use a view here.

Implement a simple many-to-many relation in a Form in OpenOffice.org's Base

I'm doing a small relational database, to be used by one person on a single computer. I chose OpenOffice.org's Base (version 3.1.1) because it's free and should be more than enough for this case. The simplified version of my problem is:
I have an Articles table, with columns: ID, Title, Content, etc....
I have a Keywords table with columns: ID, Keyword.
I have a Relations table with columns: ID, ArticleID, KeywordID
Just a basic, classic, example of a many-to-many relation.
Then I created a form (for the user using the database) using the 'Design view' in Base and linked to the Articles table, which works fine, and allows me to view, edit and created rows in the Articles table.
My problem is how to include the relation to Keywords in that same form. That is, I want the user to be able to view and choose which keyword(s) belongs to the article currently being viewed in the form.
The number of keywords is finite (probably 5-15) if that matters. A preferred setup would be a list of keywords (dynamically linked to the Keywords table of course) in the previously mentioned form I've already created with a check box in front of each keywords
I've tried Google'ing all possible keywords and I've come up with nothing applicable to my case. I belive the answer is somehow using SubForms, or maybe some SQL syntax I'm not familiar with. Any help appreciated.
To answer this in a little more detail, as it comes up early on Google search, please refer to the following video of creating the movies.odb file from scratch:
http://www.youtube.com/watch?v=GYawYO8u3_s
Some further notes on creating this:
Setting up the tables
The principle tables must have an integer primary key that is set to AutoValue
The linking table must have a multi-column primary key, and both columns must be integers
The table relationships must be set in the Relationships... dialog
The relationships disappear if Update options not changed from No action
Setting up the subform
The subform Data >> Content must be set to the mapping table
The subform Data >> Link master fields and Link slave fields must be set to the related fields (as per the Relationships... dialog discussed above)
A table control should be draw (focus must be on the subform at the time, such that the table control sits below the subform in the Form Navigator
A column should be inserted into the table control
The column Data >> Data field should be set to the ID of the related data (i.e. not that of the main form)
The column Data >> Type of list contents should be set to “sql”
The column Date >> List content should be set to “SELECT “Genre Name”, “GenreID” FROM “Genre”” (where Genre Name is the relevant field from the related table, the GenreID is the primary key of that table, and Genre is the related table)
I did some more searching and finally found a solution.
A thread explaining this very issues (among other issues), creating form for a database containing many-to-many relation in Base using a middle table, can be found at:
http://user.services.openoffice.org/en/forum/viewtopic.php?p=16159#p16159
A sample database with a functional form by one of the above thread's posters (DrewJensen) can be found and downloaded at page 2 of the above posted thread. (named movies_2.odb)
A brief description of the solution using my example tables and columns from orginial post:
The trick lies in creating a sub-form linked to the Relations table within the form I had created. That sub-form should contain a Table Control. Then a column should be created in that Table Control. The column should be asigned to the KeywordID column. The "List content" field for that column should then contain: SELECT "Keyword", "ID" FROM "Relations".
(just check out the above link if my instructions are cryptic)

Resources