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

Monday, March 26, 2012

Problem in creating Asymmetric keys

I am a novice to the SQL server. I am trying to create Asymmetric key using the query

CREATE ASYMMETRIC KEY PacificSales19 AUTHORIZATION dbo

FROM FILE = ' C:\temp\temp1.snk'

ENCRYPTION BY PASSWORD = 'ABC123!@.#$';

GO

But I alwys get the follwing error

The certificate, asymmetric key, or private key file does not exist or has invalid format.

Can anyone please guide me as to how to go ablout creating the ASYMMETRIC KEY FROM FILE.

Thanks and regards

The statement you are trying is correct - this is how you can create an asymmetric key from a file.

You should check that the specified path is correct and that the file is not corrupted. How did you generate that file?

Thanks
Laurentiu

Friday, March 9, 2012

Problem Deleting Rows

I have a table that was imported from an Excel 2003 worksheet. It has no
primary key. If I select one or more rows and try to delete them I get the
error:
Key column information is insufficient or incorrect. Too many rows were
affected by the update.
If I use QA I can delete the rows?
What is it trying to tell me here?
WaynePlease post the full DDL for your table, as well as the DELETE statement.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:e6dSRMHPGHA.3984@.TK2MSFTNGP14.phx.gbl...
I have a table that was imported from an Excel 2003 worksheet. It has no
primary key. If I select one or more rows and try to delete them I get the
error:
Key column information is insufficient or incorrect. Too many rows were
affected by the update.
If I use QA I can delete the rows?
What is it trying to tell me here?
Wayne|||> What is it trying to tell me here?
Two things. First, EM is not a good editing tool. Second, a table without
a primary key is, by definition, not a table.|||Interesting. Since I am importing from Excel I'll need to come up with some
autonumber key I guess?
Wayne
"Scott Morris" <bogus@.bogus.com> wrote in message
news:e2uUW4HPGHA.3732@.TK2MSFTNGP10.phx.gbl...
> Two things. First, EM is not a good editing tool. Second, a table
> without a primary key is, by definition, not a table.
>|||You can add an identity column to the target table and add a primary key
constraint on it.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:ORjDEQIPGHA.812@.TK2MSFTNGP10.phx.gbl...
Interesting. Since I am importing from Excel I'll need to come up with some
autonumber key I guess?
Wayne
"Scott Morris" <bogus@.bogus.com> wrote in message
news:e2uUW4HPGHA.3732@.TK2MSFTNGP10.phx.gbl...
> Two things. First, EM is not a good editing tool. Second, a table
> without a primary key is, by definition, not a table.
>

Wednesday, March 7, 2012

Problem Creating One-To-Many Relationship

Hi guys,

I'm testing some stuff. I have two tables, table1 has a primary key and table2 only has a column. When I try to create a relationship between them, SQL Server complains.

Here's my code:

Alter Table Table1
Add Constraint FK_T1 Foreign Key (T1) References Table2(T1)

And the error:

There are no primary or candidate keys in the referenced table 'Table2' that match the referencing column list in the foreign key 'FK_T1'.

Thanks
DarkneonOK guys, I found what was wrong.

I should go and kill myself for posting this question, now that I realize how stupid it is :o

Problem creating FOREIGN key

Hi,

I am using SQL Server 7.0

TABLE1
======
Fld1
Fld2
Fld3
Fld4
Fld5
Fld6

Primary Key = Fld1 + Fld2 + Fld3

TABLE2
======
Fld1
Fld2
Fld3
Fld4
Fld5

Foriegn Key = Fld5 (Referencing TABLE1.Fld3) The datatypes are
matching in both tables.

I am trying to create the foreign key by giving the following command:

ALTER TABLE TABLE2 ADD
CONSTRAINT [FK_TABLE2_TABLE1] FOREIGN KEY
(
[Fld5]
) REFERENCES TABLE1 (
[Fld3]
)
GO

This is giving the following error:

There are no primary or candidate keys in the referenced table
'TABLE1' that match the referencing column list in the foreign key
'FK_TABLE2_TABLE1'.

Any help?

Regards,
KamleshHi

It is better to post DDL (Create/Alter table statements) and example data
(as insert statements) than a pseudo schema such as yours.

The foreign key will have to match all columns of the primary key of the
referenced table.

If the values in fld3 are unique, then this may be a better candidate for
the primary key for table 1,
otherwise you may need to create a table just containing the unique values
of fld3 in table 1, where both table1 and table2 can reference it as a
foreign key.

John

"Kamlesh" <kamlesh2000@.yahoo.com> wrote in message
news:2644c0f6.0309080711.1ee199b1@.posting.google.c om...
> Hi,
> I am using SQL Server 7.0
>
> TABLE1
> ======
> Fld1
> Fld2
> Fld3
> Fld4
> Fld5
> Fld6
> Primary Key = Fld1 + Fld2 + Fld3
>
> TABLE2
> ======
> Fld1
> Fld2
> Fld3
> Fld4
> Fld5
>
> Foriegn Key = Fld5 (Referencing TABLE1.Fld3) The datatypes are
> matching in both tables.
> I am trying to create the foreign key by giving the following command:
> ALTER TABLE TABLE2 ADD
> CONSTRAINT [FK_TABLE2_TABLE1] FOREIGN KEY
> (
> [Fld5]
> ) REFERENCES TABLE1 (
> [Fld3]
> )
> GO
>
> This is giving the following error:
> There are no primary or candidate keys in the referenced table
> 'TABLE1' that match the referencing column list in the foreign key
> 'FK_TABLE2_TABLE1'.
>
> Any help?
> Regards,
> Kamlesh|||A foreign key can only refer to the Primary Key of the referenced table
(or to another combination of columns that is uniquely indexed). So if
your Table1 has a three column primary key, then the foreign key should
also consist of three columns, and they should have the same data type.

Gert-Jan

Kamlesh wrote:
> Hi,
> I am using SQL Server 7.0
> TABLE1
> ======
> Fld1
> Fld2
> Fld3
> Fld4
> Fld5
> Fld6
> Primary Key = Fld1 + Fld2 + Fld3
> TABLE2
> ======
> Fld1
> Fld2
> Fld3
> Fld4
> Fld5
> Foriegn Key = Fld5 (Referencing TABLE1.Fld3) The datatypes are
> matching in both tables.
> I am trying to create the foreign key by giving the following command:
> ALTER TABLE TABLE2 ADD
> CONSTRAINT [FK_TABLE2_TABLE1] FOREIGN KEY
> (
> [Fld5]
> ) REFERENCES TABLE1 (
> [Fld3]
> )
> GO
> This is giving the following error:
> There are no primary or candidate keys in the referenced table
> 'TABLE1' that match the referencing column list in the foreign key
> 'FK_TABLE2_TABLE1'.
> Any help?
> Regards,
> Kamlesh

Saturday, February 25, 2012

Problem creating a Foreign key Constraint

Hello, I'm having some problems trying to create this foreign key constraint:

ALTER TABLE dbo.t2_demaclie
ADD CONSTRAINT FK03_T2_DEMACLIE FOREIGN KEY (dclPerfilCompania, dclOrdenPedido)
REFERENCES DBO.T2_PEDIDOCLIENTE (cdPerfilCompania, nmOrdenPedido)


Server: Msg 547, Level 16, State 1, Line 1
ALTER TABLE statement conflicted with TABLE FOREIGN KEY constraint 'FK03_T2_DEMACLIE'. The conflict occurred in database 'Comfruta_dllo', table 't2_pedidoCliente'.

I'm sure there's no other constraint with the same name, and there's no othe one with the same columns...


Thanks a lot !!

Sounds like you have rows in t2_demaclie which don't match rows in t2_pedidocliente.

Check this first and see how you go. Something like this should do the trick (should give you zero rows):

select *
from t2_demaclie d
where not exists (select * from t2_pedidocliente p where p.cdPerfilCompania = d.dclPerfilCompania and p.nmOrdenPedido = d.dclOrdenPedido)

Rob|||Very useful ... Thank you so much !|||:) No problem.

Problem copying tables to another server with Primary and Foreign Key constrains

How can I copy a table with a Primary Key to another server's table of
the same name without receiving the following error: (Error at
Destination for Row number 489. Errors encountered so far in this
task:1.The statement has been terminated. Violation of PRIMARY KEY
constraint 'PK_INDIVIDUALS'. Cannot insert duplicate key in object
'INDIVIDUALS'.)
I want to copy about 20 interrelated cascaded tables with Primary and
Foreign Keys to another server's tables with the identical structure
and not receive the above error. I suggested dropping the tables and
recreating them, but my co-worker feel that this would not work because
of the interrelationship of the tables.
I tried to manually delete a table that is part of this group and
received Error 3726: Could not drop object 'dbo.INDIVIDUALS' because
it is referenced by a FOREIGN KEY constraint.
THE REASON FOR MY INQUIRY IS BECAUSE WE HAVE BEEN EXPERIENCING PROBLEM
WITH REPLICATION AND THESE TABLES ARE THE ARTICLES THAT WE BE
REPLICATED.
Any Suggestion?Some odd questions:
What field is the primary key? Is it the replication id? Is it an Identity
Field ? Some other field?
Instead of deleteing the target table you could try truncating it.
Your error says you are trying to load a duplicate key. The only answers are
Delete, Truncate, Drop or Remove Constraint.
What is the problem you are trying to solve? If it is just having a copy of
the database 'somewhere else', you could consider a backup and restore cycle.
--
Joseph R.P. Maloney, CSP,CCP,CDP
"war_wheelan@.yahoo.com" wrote:
> How can I copy a table with a Primary Key to another server's table of
> the same name without receiving the following error: (Error at
> Destination for Row number 489. Errors encountered so far in this
> task:1.The statement has been terminated. Violation of PRIMARY KEY
> constraint 'PK_INDIVIDUALS'. Cannot insert duplicate key in object
> 'INDIVIDUALS'.)
> I want to copy about 20 interrelated cascaded tables with Primary and
> Foreign Keys to another server's tables with the identical structure
> and not receive the above error. I suggested dropping the tables and
> recreating them, but my co-worker feel that this would not work because
> of the interrelationship of the tables.
> I tried to manually delete a table that is part of this group and
> received Error 3726: Could not drop object 'dbo.INDIVIDUALS' because
> it is referenced by a FOREIGN KEY constraint.
> THE REASON FOR MY INQUIRY IS BECAUSE WE HAVE BEEN EXPERIENCING PROBLEM
> WITH REPLICATION AND THESE TABLES ARE THE ARTICLES THAT WE BE
> REPLICATED.
> Any Suggestion?
>|||What field is the primary key? Is it the replication id? Is it an
Identity Field ? Some other field? THE PRIMARY KEY VARIES FROM TABLE
TO TABLE.
Instead of deleteing the target table you could try truncating it. I
AM NOT A T-SQL PROGRAMMER SO IN NON PROGRAMMING TERMS - CAN I DROP THE
KEYS ON THE DESTINATION TABLE(S) I.E. PRIMARY AND FOREIGN KEYS THEN
COPY THE NEW TABLES TO THE DESTINATION? WOULD THIS RE-ESTABLISH THE
ORIGINAL PRIMARY AND FOREIGN KEYS WITHOUT CORRUPTING THE
DATABASE/TABLES AND THEIR RELATIONSHIPS?
Your error says you are trying to load a duplicate key. The only
answers are Delete, Truncate, Drop or Remove Constraint. SAME QUESTION
AS ABOVE, BUT PERHAPS THE REMOVE CONTRAINT OPTION WOULD WORK. NEW
QUESTION: WOULD SQL LET ME REMOVE A CONTRAINT WITH INTER-RELATIONSHIPS
TO OTHER TABLES OR WOULD IT FAIL BECAUSE OF THE INTER-RELATIONSHIPS.
What is the problem you are trying to solve? If it is just having a
copy of the database 'somewhere else', you could consider a backup and
restore cycle. THE PROLEM IS THAT THESE TABLES WOULD BE REPLICATE IF
REPLICATION WERE WORKING. REPLICATION HAS NOT BEEN WORKING FOR ABOUT A
MONTH SO THE PRIMARY AND SECONDARY DATABASES ARE OUT OF SYNC. IF THE
PRIMARY SERVER GOES DOWN WE WOULD BE MISSING A MONTHS WORTH OF CHANGES.
ERGO BACK TO MY ORIGINAL QUESTION (I want to copy about 20
interrelated cascaded tables with Primary and Foreign Keys to another
server's tables with the identical structure and not receive the above
error.
Thanks for you response. I am trying to get suggestions for my PART
TIME T-SQL programmer.

Monday, February 20, 2012

Problem connecting to SQL Server over the internet

I have opened ports 1433 and 1434 on a SQL Server on our network to allow
our customers to receive a monthly subscription "key" for the software they
lease from us. Within an encrypted Stored Procedure I am using the
OPENDATASOURCE method with a connect string containing our IP address. It is
working on 90% of the sites. However some of the sites are receiving an
error:
Server: Msg 17, Level 16, State 1, Procedure PLSPSYS_ALTER_KEYSP_REMOTE,
Line 37
SQL Server does not exist or access denied.
On most of the servers where the procedure is WORKING, a peek at the
firewall configuration using Shields-Up service from Gibson Research shows
that ports 1433 and 1434 are in Stealth mode. But, as I said, the connection
is still operating just fine. All sites, including the ones that don't work,
have the TCP/IP protocol enabled in the Client Network Utility on Port 1433.
So I am at a loss to figure out why the Internet connection is not working
at some sites. Any ideas?
Also, is there another way that I can distribute the "key" without user
intervention using "back-end" programs or procedures? Is there a way to
connect and retieve data via port 80 which is usually left open for outbound
requests? Thanks in advance...
I would make network traces at the problem site and either review the
firewall logs or
make simulataneous traces on the server. This sounds like a tcp issue not
a SQL issue.
Verify that the 3 way tcp handshake is completing. The login packet isn't
sent until this completes.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.
|||Thank you both for your replies. I will make sure that the TCP issues are
resolved at the client sites before looking any further.
"John Kotuby" <jkotuby@.snet.net> wrote in message
news:undiWF%23TEHA.2028@.TK2MSFTNGP11.phx.gbl...
> I have opened ports 1433 and 1434 on a SQL Server on our network to allow
> our customers to receive a monthly subscription "key" for the software
they
> lease from us. Within an encrypted Stored Procedure I am using the
> OPENDATASOURCE method with a connect string containing our IP address. It
is
> working on 90% of the sites. However some of the sites are receiving an
> error:
> Server: Msg 17, Level 16, State 1, Procedure PLSPSYS_ALTER_KEYSP_REMOTE,
> Line 37
> SQL Server does not exist or access denied.
> On most of the servers where the procedure is WORKING, a peek at the
> firewall configuration using Shields-Up service from Gibson Research shows
> that ports 1433 and 1434 are in Stealth mode. But, as I said, the
connection
> is still operating just fine. All sites, including the ones that don't
work,
> have the TCP/IP protocol enabled in the Client Network Utility on Port
1433.
> So I am at a loss to figure out why the Internet connection is not working
> at some sites. Any ideas?
> Also, is there another way that I can distribute the "key" without user
> intervention using "back-end" programs or procedures? Is there a way to
> connect and retieve data via port 80 which is usually left open for
outbound
> requests? Thanks in advance...
>

Problem connecting to SQL Server over the internet

I have opened ports 1433 and 1434 on a SQL Server on our network to allow
our customers to receive a monthly subscription "key" for the software they
lease from us. Within an encrypted Stored Procedure I am using the
OPENDATASOURCE method with a connect string containing our IP address. It is
working on 90% of the sites. However some of the sites are receiving an
error:
Server: Msg 17, Level 16, State 1, Procedure PLSPSYS_ALTER_KEYSP_REMOTE,
Line 37
SQL Server does not exist or access denied.
On most of the servers where the procedure is WORKING, a peek at the
firewall configuration using Shields-Up service from Gibson Research shows
that ports 1433 and 1434 are in Stealth mode. But, as I said, the connection
is still operating just fine. All sites, including the ones that don't work,
have the TCP/IP protocol enabled in the Client Network Utility on Port 1433.
So I am at a loss to figure out why the Internet connection is not working
at some sites. Any ideas?
Also, is there another way that I can distribute the "key" without user
intervention using "back-end" programs or procedures? Is there a way to
connect and retieve data via port 80 which is usually left open for outbound
requests? Thanks in advance...I would make network traces at the problem site and either review the
firewall logs or
make simulataneous traces on the server. This sounds like a tcp issue not
a SQL issue.
Verify that the 3 way tcp handshake is completing. The login packet isn't
sent until this completes.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||Thank you both for your replies. I will make sure that the TCP issues are
resolved at the client sites before looking any further.
"John Kotuby" <jkotuby@.snet.net> wrote in message
news:undiWF%23TEHA.2028@.TK2MSFTNGP11.phx.gbl...
> I have opened ports 1433 and 1434 on a SQL Server on our network to allow
> our customers to receive a monthly subscription "key" for the software
they
> lease from us. Within an encrypted Stored Procedure I am using the
> OPENDATASOURCE method with a connect string containing our IP address. It
is
> working on 90% of the sites. However some of the sites are receiving an
> error:
> Server: Msg 17, Level 16, State 1, Procedure PLSPSYS_ALTER_KEYSP_REMOTE,
> Line 37
> SQL Server does not exist or access denied.
> On most of the servers where the procedure is WORKING, a peek at the
> firewall configuration using Shields-Up service from Gibson Research shows
> that ports 1433 and 1434 are in Stealth mode. But, as I said, the
connection
> is still operating just fine. All sites, including the ones that don't
work,
> have the TCP/IP protocol enabled in the Client Network Utility on Port
1433.
> So I am at a loss to figure out why the Internet connection is not working
> at some sites. Any ideas?
> Also, is there another way that I can distribute the "key" without user
> intervention using "back-end" programs or procedures? Is there a way to
> connect and retieve data via port 80 which is usually left open for
outbound
> requests? Thanks in advance...
>