Re: Distinct insert

From: Robert (Robert_at_discussions.microsoft.com)
Date: 08/26/04


Date: Thu, 26 Aug 2004 05:55:04 -0700

Unfortunately I do not have the create table SQL statements

What I am trying to accomplish is importing data from an excel file into a
SQL database. To make it easier to work with I simply straight imported the
excel file into a new table in the SQL database (AutoExpt). Accounts is one
of the tables that I need to import into. I do know that the OID for the
accounts table is not automatically generated, and must be generated manually.

In the AutoExpt table there is a listing of vechiles and what accounts
maintenance should be charged to. I can add the vechiles fine to the
Equipment table (Not listed here because it works just fine). However another
table EquipmentFeature is linked to the Equipment table. It contains things
such as account numbers, and the department that the vechile belongs to.

>From what I can tell I can not add records to the Equipment feature table
such as the account number because they do not exist in the Accounts table.
So the solution is to first add all the distinct account numbers into the
accounts table. This also applies to the departments table as well.

I do have a backup of the database so I can fool aroudn with it all I want
without worry of data loss or damage, plus I am working on a dev server so no
actual users are accessing the database. I found that I can add duplicate
records in the accounts table and the departments table, however I have found
that I can't remove some duplicates in the departments table because it
claims that a record needs to exist in the General table first.

My theory is that if I add only the distinct account numbers and departments
I should be fine, and it should stop telling me that "A record must exist in
the accounts table first"

Unfortunately the company that makes the software is not offering much
support on importing the data. So I am left to figure it out myself.

"Hugo Kornelis" wrote:

> On Wed, 25 Aug 2004 12:55:03 -0700, Robert wrote:
>
> >I am trying to insert a record id primary at the same time that I am trying
> >to insert a Distinct Account number.
> >
> >The insert statement is something kind of like this:
> >
> >insert into Accounts (AccountsOID,Account)
> > select Distinct "Rec NO" + 100 as AccountsOID, "LIC TAG" as Account from
> >AutoExpt
> >
> >In the AutoExpt table there are multiple occurrences of "LIC TAG" values all
> >of which need to be put into the Accounts table, however there must be only
> >one entry for the Lic tag in the accounts table. The Rec No +100 is just to
> >create a unique primary key for the AccountsOID.
> >
> >Is there anyway I can get only the Distinct Lic Tag's, but at the same time
> >get a unique primary key for them.
> >
> >Thanks,
>
> Hi Robert,
>
> Please provide DDL (CREATE TABLE statements, with constraints), sample
> data (as INSERT statements), expected output and a description of the
> business problem you're trying to solve.
>
> http://www.aspfaq.com/etiquette.asp?id=5006
> http://vyaskn.tripod.com/code.htm#inserts
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>



Relevant Pages

  • Re: SMS site server HDD allocation
    ... system roles will be placed, where the SQL database will be, etc. ... The Client Installation Wizard is used to remotely install, or push, the ... If you are, and you should be, using Advanced Security, all the SMS 2003 ... Connection accounts to allow the clients to connect and write to the ...
    (microsoft.public.sms.admin)
  • Re: SMS site server HDD allocation
    ... system roles will be placed, where the SQL database will be, etc. ... The Client Installation Wizard is used to remotely install, or push, the ... If you are, and you should be, using Advanced Security, all the SMS 2003 ... Connection accounts to allow the clients to connect and write to the ...
    (microsoft.public.sms.admin)
  • SPS and existing authentication
    ... I have an web site with about 5000 users, with forms authentication. ... accounts are in sql database. ... Now i need sharepoint portal server added to ...
    (microsoft.public.sharepoint.portalserver.development)
  • RE: MOSS 2007 import users errors
    ... added a patch to fix the incorrectly-formatted URLs by changing the forward ... was able to successfully complete the AD import and all the user profile data ... I thought of this originally, but since 327 accounts made it in, I _assumed_ ... but I would have guessed that importing users works... ...
    (microsoft.public.sharepoint.portalserver)
  • RE: MOSS 2007 import users errors
    ... No other AD fields are importing. ... was able to successfully complete the AD import and all the user profile data ... I changed the following stored procedures in the SharedServices_Search_DB: ... I thought of this originally, but since 327 accounts made it in, I _assumed_ ...
    (microsoft.public.sharepoint.portalserver)