Showing posts with label key. Show all posts
Showing posts with label key. Show all posts

Tuesday, March 27, 2012

entry number thousand from 3 Tables with primary key number

Hi!
I have 3 tables with a primary key (number integer 4 ) and I have a datetime
field date_ (datetime 8) with the following value: 16.01.2003 00:00:04.
The primary key is not starting with one and some numbers are also missing.
Now I want to get the entry number thousand in the order after the date_
field with all rows from this 3 tables.
How must my select statement look like?
ThanksCan you further elaborate the following sentence:
Now I want to get the entry number thousand in the order after the date_
field with all rows from this 3 tables.
"Hubert Mayr" <huma1@.gmx.net> wrote in message
news:1068474664.222762@.news.liwest.at...
> Hi!
> I have 3 tables with a primary key (number integer 4 ) and I have a
datetime
> field date_ (datetime 8) with the following value: 16.01.2003 00:00:04.
> The primary key is not starting with one and some numbers are also
missing.
> Now I want to get the entry number thousand in the order after the date_
> field with all rows from this 3 tables.
> How must my select statement look like?
> Thanks
>

Sunday, February 19, 2012

Enterprise Manager and Foreign Key Constraints

Hi all,
OK, I'm getting an error in Enterprise Manager that I don't understand. I have three tables. One is a list of hospitals - id, address details etc. Another is a list of stock - id, description etc. The third (called "hosp_stock") is supposed to be the one that links them. It has its own autonumber primary key, hospital id, stock id and a stock amount field.

Hopefully, you're now thinking "Ah, so he just needs to create a one-to-many relationship between stock/id and hosp_stock/stock_id, and another one between hospitals/id and hosp_stock/hospital_id.

That's what I thought, but when I go to save this relationship, I get the following error:

ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_hosp_stock_int_loc'. The conflict occurred in database 'patientline', table 'int_loc', column 'in_id'.

(The "int_loc" table is the hospitals list, the "in_id" column is its primary key that I linked the hosp_stock/hospital_id column to.)

I'm not sure that I've made this very clear, all I know is its a common way of creating such relationships. If you're familiar with Enterprise Manager, does any of it sound wrong? Why will it happily create a link between the stock table and the intermediate hosp_stock table, but not between hosp_stock and the hospitals table?

NB - if it's any help, I managed to get it to accept the relationship after deleting all the data existing in the hosp_stock table, but now I can't put any data back in.

Cheers for any advice.

Spud.It's ok chaps, I figured it out :) For the future reference of any interested parties: make sure that when you're entering information in a foreign key table, make sure that value exists in the correspodning column of the primary key table. For example, don't assume your hospital ID numbers begin at "1" and merrily sit putting data in for this non-existent hospital, otherwise you just get a lot of beeps and a sore head.

Spud.

Enterprise Manager 2000 vs 2005

Maybe I just haven't found the right place yet, but...
1. In 2000 you could hold down the control key, select several tables and
script them out into 1 file... why doesn't this work in 2005 (or how do you
do it in 2005) ?
2. In 2000 you could right click on a table and quickly export its
contents... how in 2005 ?
When using SSIS...
So I connect to Integration services... I expand my stored packages... MSDB
folder... I see the packages there... Is there a way to "open them" in
design view from EM ?
Thanks !Hi Rob
"Rob" wrote:
> Maybe I just haven't found the right place yet, but...
> 1. In 2000 you could hold down the control key, select several tables and
> script them out into 1 file... why doesn't this work in 2005 (or how do you
> do it in 2005) ?
You can script multiple objects by clicking the database then choosing
task/generate scripts and choose from them, a mixture of multiple objects of
different types can be chosen.
> 2. In 2000 you could right click on a table and quickly export its
> contents... how in 2005 ?
Again at database level, tasks and export data to get the wizard..
> When using SSIS...
> So I connect to Integration services... I expand my stored packages... MSDB
> folder... I see the packages there... Is there a way to "open them" in
> design view from EM ?
No, you need to used BIDS ( SQL Server Business Intelligence Development
Studio )
> Thanks !
>
John|||Thanks for the response John...
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:DEF8B71A-5370-4A3F-899C-B8D8D3296D0B@.microsoft.com...
> Hi Rob
> "Rob" wrote:
>> Maybe I just haven't found the right place yet, but...
>> 1. In 2000 you could hold down the control key, select several tables and
>> script them out into 1 file... why doesn't this work in 2005 (or how do
>> you
>> do it in 2005) ?
> You can script multiple objects by clicking the database then choosing
> task/generate scripts and choose from them, a mixture of multiple objects
> of
> different types can be chosen.
>> 2. In 2000 you could right click on a table and quickly export its
>> contents... how in 2005 ?
> Again at database level, tasks and export data to get the wizard..
>> When using SSIS...
>> So I connect to Integration services... I expand my stored packages...
>> MSDB
>> folder... I see the packages there... Is there a way to "open them" in
>> design view from EM ?
> No, you need to used BIDS ( SQL Server Business Intelligence Development
> Studio )
>> Thanks !
> John

Enterprise Manager 2000 vs 2005

Maybe I just haven't found the right place yet, but...
1. In 2000 you could hold down the control key, select several tables and
script them out into 1 file... why doesn't this work in 2005 (or how do you
do it in 2005) ?
2. In 2000 you could right click on a table and quickly export its
contents... how in 2005 ?
When using SSIS...
So I connect to Integration services... I expand my stored packages... MSDB
folder... I see the packages there... Is there a way to "open them" in
design view from EM ?
Thanks !
Hi Rob
"Rob" wrote:

> Maybe I just haven't found the right place yet, but...
> 1. In 2000 you could hold down the control key, select several tables and
> script them out into 1 file... why doesn't this work in 2005 (or how do you
> do it in 2005) ?
You can script multiple objects by clicking the database then choosing
task/generate scripts and choose from them, a mixture of multiple objects of
different types can be chosen.
> 2. In 2000 you could right click on a table and quickly export its
> contents... how in 2005 ?
Again at database level, tasks and export data to get the wizard..

> When using SSIS...
> So I connect to Integration services... I expand my stored packages... MSDB
> folder... I see the packages there... Is there a way to "open them" in
> design view from EM ?
No, you need to used BIDS ( SQL Server Business Intelligence Development
Studio )

> Thanks !
>
John
|||Thanks for the response John...
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:DEF8B71A-5370-4A3F-899C-B8D8D3296D0B@.microsoft.com...
> Hi Rob
> "Rob" wrote:
> You can script multiple objects by clicking the database then choosing
> task/generate scripts and choose from them, a mixture of multiple objects
> of
> different types can be chosen.
> Again at database level, tasks and export data to get the wizard..
> No, you need to used BIDS ( SQL Server Business Intelligence Development
> Studio )
> John

Enterprise Manager 2000 vs 2005

Maybe I just haven't found the right place yet, but...
1. In 2000 you could hold down the control key, select several tables and
script them out into 1 file... why doesn't this work in 2005 (or how do you
do it in 2005) ?
2. In 2000 you could right click on a table and quickly export its
contents... how in 2005 ?
When using SSIS...
So I connect to Integration services... I expand my stored packages... MSDB
folder... I see the packages there... Is there a way to "open them" in
design view from EM ?
Thanks !Hi Rob
"Rob" wrote:

> Maybe I just haven't found the right place yet, but...
> 1. In 2000 you could hold down the control key, select several tables and
> script them out into 1 file... why doesn't this work in 2005 (or how do y
ou
> do it in 2005) ?
You can script multiple objects by clicking the database then choosing
task/generate scripts and choose from them, a mixture of multiple objects of
different types can be chosen.
> 2. In 2000 you could right click on a table and quickly export its
> contents... how in 2005 ?
Again at database level, tasks and export data to get the wizard..

> When using SSIS...
> So I connect to Integration services... I expand my stored packages... MSD
B
> folder... I see the packages there... Is there a way to "open them" in
> design view from EM ?
No, you need to used BIDS ( SQL Server Business Intelligence Development
Studio )

> Thanks !
>
John|||Thanks for the response John...
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:DEF8B71A-5370-4A3F-899C-B8D8D3296D0B@.microsoft.com...
> Hi Rob
> "Rob" wrote:
>
> You can script multiple objects by clicking the database then choosing
> task/generate scripts and choose from them, a mixture of multiple objects
> of
> different types can be chosen.
> Again at database level, tasks and export data to get the wizard..
>
> No, you need to used BIDS ( SQL Server Business Intelligence Development
> Studio )
>
> John

Wednesday, February 15, 2012

enterprise key?

has anyone heard of this? A unique key separate from primary keys? Something
that stands apart from say, clientID, employeeID, companyID,...? thx, -hazzThere is the ability to create a unique index and a unique constraint. I've
never heard of "enterprise keys" with specific relation to SQL Server.
http://www.aspfaq.com/
(Reverse address to reply.)
"Hazz" <hazz@.nospameroosonic.net> wrote in message
news:#A8K3arIFHA.3108@.tk2msftngp13.phx.gbl...
> has anyone heard of this? A unique key separate from primary keys?
Something
> that stands apart from say, clientID, employeeID, companyID,...?
thx, -hazz
>|||Are you looking for a uniqueidentifier data type? It can create unique
values using NEWID().
Simon Worth
"Hazz" <hazz@.nospameroosonic.net> wrote in message
news:%23A8K3arIFHA.3108@.tk2msftngp13.phx.gbl...
> has anyone heard of this? A unique key separate from primary keys?
Something
> that stands apart from say, clientID, employeeID, companyID,...?
thx, -hazz
>|||Thank you Aaron.
"Aaron [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:uXMBpdrIFHA.3484@.TK2MSFTNGP12.phx.gbl...
> There is the ability to create a unique index and a unique constraint.
> I've
> never heard of "enterprise keys" with specific relation to SQL Server.
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Hazz" <hazz@.nospameroosonic.net> wrote in message
> news:#A8K3arIFHA.3108@.tk2msftngp13.phx.gbl...
> Something
> thx, -hazz
>|||Thank you Simon.
"Simon Worth" <REMOVEFIRST_simon.worth@.gmail.com> wrote in message
news:%23MBjFgyIFHA.2132@.TK2MSFTNGP14.phx.gbl...
> Are you looking for a uniqueidentifier data type? It can create unique
> values using NEWID().
> --
> Simon Worth
>
> "Hazz" <hazz@.nospameroosonic.net> wrote in message
> news:%23A8K3arIFHA.3108@.tk2msftngp13.phx.gbl...
> Something
> thx, -hazz
>