This is a case:
I wanna make sure of the thing I'm going to do is right or wrong.
The case:
lets say I have two tables on sql server with different names of two of them. and I have created an index for two of the tables with the same indexes names but I typed in every index query or script (use table name) and I specified the table name in the script.
the question, would I get conflict values in the indexes if I run the script or the index triggered?
Related
I have MS Access tables that are indexed but accept duplicates. Tables have been transferred to SQL Server and linked to Access.
How do you replicate primary keys that accept duplicates?
You should consider using SSMA
Sql Server Migration Assistant for Access
It can move up tables.
It will move up related data, setup PK columns for you.
It will maintain, and create relationships for you.
It will maintain and create all indexes you have now.
If you just have a few tables, say 2-5 tables? Then sure, just import them and setup the relatonships and indexs your self.
However, the last few migrations of data from Access to SQL server? There was in excess of 80 tables - and HUGE numbers of reatonships, indexes, and of course PK settings. The migration wizard thus can send up all of the tables - and setup all of the tables correctly on SQL server for you. Including PK values, FK values (Foreign Keys (related tables)),
and even constraints are in most cases correctly move up to sql server.
what is nice, is then you can re-link the tables in your Access application, and you now using SQL server for the back end database.
SSMAA can be found here:
https://www.microsoft.com/en-us/download/details.aspx?id=54255
I think you're confusing an "index" with a "primary key".
An "index" is a structure that helps optimise queries. Indexes don't have to be unique. A "primary key" is a logical constraint on a column which requires that all values in the column are unique.
It sounds like what you want to do is import the data into SQL and create an index to help speed up queries, but where that index is not constrained to be unique.
Here's the syntax to do that. Suppose we have some table T:
create table T(i int, j int, k int);
We want to create an index on column i to speed up queries, but i is not unique. To do that we create a regular (non unique) index:
create index MyIndexName on T(i);
As a rule, I tend to name my indexes based on what they are indexing. So in the above case I wouldn't call the index "MyIndexName", I would call it something like ix_T_i.
I have a tool by Oracle called SQL Developer. I have created a table called multicarrier_ClaimTraceDetails. Before this I tried creating the same table with name (actually same name but with lower case, which I had to delete it and create this new one). But when I to see the structure of table, I see every column twice in the table.
I have below questions about this behavior:
Why is it happening?
How can I correct it?
Didn't my previous/old table got deleted? (though I don't see it in the list of tables in left panel)
My company has an application with a bunch of database tables that used to use a sequence table to determine the next value to use. Recently, we switched this to using an identity property. The problem is that in order to upgrade a client to the latest version of the software, we have to change about 150 tables to identity. To do this manually, you can right click on a table, choose design, change (Is Identity) to "Yes" and then save the table. From what I understand, in the background, SQL Server exports this to a temporary table, drops the table and then copies everything back into the new table. Clients may have their own unique indexes and possibly other things specific to the client, so making a generic script isn't really an option.
It would be really awesome if there was a stored procedure for scripting this task rather than doing it in the GUI (which takes FOREVER). We made a macro that can go through and do this, but even then, it takes a long time to run and is error prone. Something like: exec sp_change_to_identity 'table_name', 'column name'
Does something like this exist? If not, how would you handle this situation?
Update: This is SQL Server 2008 R2.
This is what SSMS seems to do:
Obtain and Drop all the foreign keys pointing to the original table.
Obtain the Indexes, Triggers, Foreign Keys and Statistics of the original table.
Create a temp_table with the same schema as the original table, with the Identity field.
Insert into temp_table all the rows from the original table (Identity_Insert On).
Drop the original table (this will drop its indexes, triggers, foreign keys and statistics)
Rename temp_table to the original table name
Recreate the foreign keys obtained in (1)
Recreate the objects obtained in (2)
I've searched for this thingy a lot.. and I can not find a solution since I'm beginner in SQL itself.
I used to edit games database. now, I need to create a new table with 1 row called "CodeName128" and it should contain the same value many times..
when I place something like
CODE_NAME1
CODE_NAME1
it tells me No rows was updated blabla which means this table already have this code.
how can I get over it and enable the duplication in table?
Live example:
You must be having Primary key or Unique key defined on that column which is not allowing you to enter the duplicate values. The keys must be defined for a reason, so its not advisable to remove those, still if you think that duplicate values are required for that column, you have to alter the table structure and remove those constraints from that column.
I am using SQL Server 2000 and I have two databases that both replicate (transactional push subscription) to a single database. I need to know which database the records came from.
So I want to add a fixed column specified in the publication to my table so I can tell which database the row originated from.
How do I go about doing this?
I would like to avoid altering the main databases mostly due to the fact there are many tables I would need to do this to. I was hoping for some built in feature of replication that would do this for me some where. Other than that I would go with the view idea.
You could use a calculated column Use the following on the two databases:
ALTER TABLE TableName ADD
MyColumn AS 'Server1'
Then just define the single "master" database to use a VARCHAR column (or whatever you want) that you fill using the calculated columns value.
You can create a view, which adds the "constant" column, and use it as a replication source.
So the solution for me was to set up the replication publications to allow transformations and create a DTS package for each site that appends the siteid into the tables to keep the ids unique as I can't use guids.