473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Modify Index

Hi all,
I have been left to modify an old unique index, which no longer works,
as the two fields, which were used, are no longer unique. I’ve found two
others that are unique. But as I’m new to this I need some advice first.
What happens if one table inserts from another (the second containing
the index). However if there is a duplicate will the records which are
not duplicates be inserted? How could I insure this?

Thanks

Sam


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
4 2736

"Sam G" <mo**@spamhole.com> wrote in message
news:3f*********************@news.frii.net...
Hi all,
I have been left to modify an old unique index, which no longer works,
as the two fields, which were used, are no longer unique. I've found two
others that are unique. But as I'm new to this I need some advice first.
What happens if one table inserts from another (the second containing
the index). However if there is a duplicate will the records which are
not duplicates be inserted? How could I insure this?

Thanks

Sam


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Your question isn't completely clear, but I guess you're adding a new
unique index, or possibly a primary key constraint, to a table. If you're
asking what will happen if you try to insert multiple rows which include
duplicate values for those columns, then the whole statement will be
cancelled, and no rows will be inserted.

If that doesn't answer your question, perhaps you could give some more
detail on exactly what you need to do?

Simon
Jul 20 '05 #2


Yes sorry I don’t think I was that clear!
Basically we have two tables: account_stage and account_live. The
contractors set up an index on account_live, which had a unique
constraint batch_number and sequence_number. The company that sends us
information is no longer able to ensure this uniqueness. I have found
another combination in the existing account_live table (ie Rreg_number
and year_code) this is unique. I have therefore changed the account_live
table to the latter index.

We get two files from this outside company, which is poured, into the
account_stage table. The first file being a daily file the second a
monthly. The monthly is a ‘catch-all’ and would include most of the
information the daily files would have (and fill in the holes missed).

I want to ensure that both the daily and monthly load their information.
The monthly may/will have the same reg_number and year_code which match
some daily files already in the account_live table.

I just want to be able to load the monthly with just those missing
items. Is this feasible?
Many thanks
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Sam G <mo**@spamhole.com> wrote in message news:<3f*********************@news.frii.net>...
Yes sorry I don?t think I was that clear!
Basically we have two tables: account_stage and account_live. The
contractors set up an index on account_live, which had a unique
constraint batch_number and sequence_number. The company that sends us
information is no longer able to ensure this uniqueness. I have found
another combination in the existing account_live table (ie Rreg_number
and year_code) this is unique. I have therefore changed the account_live
table to the latter index.

We get two files from this outside company, which is poured, into the
account_stage table. The first file being a daily file the second a
monthly. The monthly is a ?catch-all? and would include most of the
information the daily files would have (and fill in the holes missed).

I want to ensure that both the daily and monthly load their information.
The monthly may/will have the same reg_number and year_code which match
some daily files already in the account_live table.

I just want to be able to load the monthly with just those missing
items. Is this feasible?
Many thanks
Sam
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


It's always best to post CREATE TABLE statements, including keys etc,
but it looks like you need to do this:

insert into dbo.account_live
(column1, column2, ...)
select column1, column2, ...
from dbo.account_stage s
where not exists (
select *
from dbo.account_live l
where s.Rreg_number = l.Rreg_number and
s.year_code = l.year_code)

This assumes that both tables have the same structure (or at least
that they both have Rreg_number and year_code). To speed this up, it
would probably be worth creating an index on the same columns on
account_stage, if you haven't done so already.

Simon
Jul 20 '05 #4

That's great Simon.
many thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
I am using code provided by Mr. Steele that allows for my MDB to dynamically connect to remote SQL server databases. The code works fine as follows: Type TableDetails TableName As String...
2
by: TT (Tom Tempelaere) | last post by:
Hey there, I'm having trouble finding the right XPath expression. The XML file I'm parsing contains an element Heads which contains sereveral Head elements. These Head elements have several Row...
5
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a...
7
by: mp | last post by:
X-No-Archive How do I go about modifying one character in a string elegantly? In other words, I want a function that will change 'aaaa' to 'aaza', given the index 2 of the character in the string....
3
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current page in a browser?...
5
by: nasse | last post by:
I am getting the following error msg whenever I try to login. I tried to turn my output_buffering = On in my php.ini but is not working for me. Would you please help me: Warning: Cannot modify...
23
by: no1zson | last post by:
I have been adding buttons to my GUI to manipulate list data. I added a Delete button this morning in case I decide I no longer needed a particular element. I am now working on a modify button, in...
1
by: macupryk | last post by:
Need to modify the stored proc where we can add the REP_NAME. to an existing crystal report. I will also need to order by REP_NAME and group by REP_NAME. Many customer id's can belong to one Sales...
1
mikek12004
by: mikek12004 | last post by:
In top of my index I include funcs.php which is : <?php function GetCartId() { //if user logged on use username as identification, else use coockie for anonymous user if ($_SESSION==1) {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.