Contraint Violation When Reading From Database

Apr 4, 2008

I have created a typed-dataset AuthorsDataSet and created a table in with name Authors, manually by right-click > New > Table. I have kept the data-types, sizes and contstriants exactly same as the table in the database, though I have kept the Column names different. I am filling the AuthorsDataSet with the following code on Form_Loadif (!IsPostBack)

{      SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString);

      SqlCommand cmd = new SqlCommand("SELECT au_id, au_lname, au_fname, phone, address, city, state, zip, contract FROM authors", conn);      using (SqlDataAdapter da = new SqlDataAdapter(cmd))

      {

            conn.Open();

            da.Fill(ds.Authors);

            grdAuthors.DataSource = ds.Authors;

            grdAuthors.DataBind();

            conn.Close();

      }

      conn.Dispose();

      cmd.Dispose();

}

The connection string is as follows:<connectionStrings>

      <add name="pubsConnectionString" connectionString="Data Source = localhost; Initial Catalog = pubs; Integrated Security = SSPI"/>

</connectionStrings>

The following error occurs when I run the page

System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

View 3 Replies


ADVERTISEMENT

Bcp_sendrow Causing Unhandled Exception (0xC0000005: Access Violation Reading Location 0x00000123)

Jun 24, 2007

Hi,

Background:

This could be a simple C++ issue as I am not that familiar with the language. I am trying to prototype a small program to test the performance of inserting data using the BCP interface. I want to BCP data that my program generates and passes via program variables.



I have narrowed the issue down to a sprintf call. Following are two variations of the code - one that works and one that does not. The error happens when I try to execute the bcp_sendrow() call.



What is the appropriate way to create / send string data to the BCP interface. Any good examples available? I have created the following from the BulkCopyFromVariables example on the Microsoft SQL Server downloads site.



Thanks in advance, Kerry



---- Works ----




Code Snippet

for(idx=1; idx<=5; idx++){
//sprintf(k1, "%d", idx); //does not work...
sprintf(k1, "oo"); //works....

if ( (SendRet = bcp_sendrow(hdbc1) ) != SUCCEED ) {
printf("bcp_sendrow(hdbc1) Failed");
Cleanup();
return(9);
}
}






--- Causes Access Violation ----




Code Snippet

for(idx=1; idx<=5; idx++){
sprintf(k1, "%d", idx); //does not work...
//sprintf(k1, "oo"); //works....

if ( (SendRet = bcp_sendrow(hdbc1) ) != SUCCEED ) {
printf("bcp_sendrow(hdbc1) Failed");
Cleanup();
return(9);
}
}










--- Additional information ---

---------------------------
Target Table Definition
---------------------------



Code SnippetCREATE TABLE PtTest(
[ID] [int] IDENTITY(1,1) NOT NULL,
[PtID] [int] NOT NULL,
[ParamID] [nchar](10) NULL DEFAULT ((200)), --Above example trying to insert data here via k1 variable...
[ParamValue] [nchar](10) NULL DEFAULT ((200)),
[InsDate] [datetime] NULL DEFAULT (getdate()),
)


----------------------------




-----------------
Bind statements
-----------------



Code Snippet

int idx;
char k1[5];
char *terminator = "";


retcode = bcp_bind(hdbc1, (BYTE *)&idx, 0, sizeof(DBINT), NULL, 0, SQLINT4, 2);
if ( (retcode != SUCCEED) ) {
printf("bcp_bind(hdbc1) Failed");
Cleanup();
return(9);
}

retcode = bcp_bind(hdbc1, (BYTE *)&k1, 0, SQL_VARLEN_DATA, (UCHAR*)terminator, 1, SQLCHARACTER, 3);
if ( (retcode != SUCCEED) ) {
printf("bcp_bind(hdbc1) Failed");
Cleanup();
return(9);
}





Note: there are other bind statements...
-----------------

View 3 Replies View Related

Need Some Help With Check Contraint In SQL2005

Aug 29, 2006

Hi,

I have this table which contains 2 datetime fields called Startdate & enddate

Startdate cannot contain NULL
Enddate can because it can be a single day event or a period.

If enddate is not null it must be later than startdate
i created this checkconstraint

enddate > startdate

But i also fires when enddate = NULL

Someone knows howto do this?

Cheers Wim

View 4 Replies View Related

Creditcard Validation Contraint

Jul 9, 2002

Well I looking voor a nice way to check a creditcard number with a contraint. I don't want to do it in the client software. So I thought I could use a contraint.

But i can't get it right. Has anyone an idea? Please help me I'm desperate!

Trying is the first step toward failure

-Homer Simpson

View 4 Replies View Related

Default Contraint *** RESOLVED***

Aug 16, 2005

You can't have but one default contraint in a DB named
df_revisiondate Default getdate()

I thought that sense they were being created on different Tables that it would not matter. It was a way to maintain a type of consistency by giving them the same name. However, it SEEMS to have caused all my tables to crash.

thanks!

View 5 Replies View Related

Delete Database File On Server -&> Sharing Violation

Oct 17, 2007

Hi,I have some database files (.MDF, .LDF,...) on the server. When I tryto delete them, the warning "Cannot delete file: There has been asharing violation. The source or destination file may be in use."appears.Since I am new to the environment I don't know where the files comefrom and where they might be used.Can anybody tell me what to do to delete those files?Thank you.

View 36 Replies View Related

Database Constaint Violation Error In SQL For Great Plains

Feb 1, 2006

Hi there. We're doing a save on a MS Great Plains with SQL Server screen and get the following error:
"A save operation on table 'WS_Time_Sheet_TRX_WORK' failed because a database constraint was violated."

If I hit More Info it says:
[Microsoft][ODBC SQL Server Driver][SQL Server]INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_WS10702_UPR00100'. The conflict occurred in database 'NSP', table 'U00100PR', column 'EMPLOYID'.

I know these messages probably make perfect sense to you guys, but I'm a newbie. Can you point me in the right direction? My thinking is that maybe I should force the foreign key constraint using the "WITH NOCHECK" option or maybe the wrong data type is mapped between the two tables sharing the Foreign Key and the key should be deleted and recreated.

Any help you can provide would be most appreciated! Assume that I'm a newbie and that I know very little. You won't hurt my feelings if you "dumb it down" so I can understand where to begin! lol I'm not even entirely sure I know where to look to edit the connection in the first place.

View 1 Replies View Related

Left Join Contraint Problem With Respect To Parameters

Dec 1, 2006

I have a query in and OLEDB Source which results in incorrect rows returned due to its structure:
SELECT table1.ABCD, table2.BAAA, table3.CAAA, table4.DAAA, table5.EAAAFROM table1LEFT OUTER JOINtable3 ON table1.ABCD = table3.BCDE LEFT OUTER JOINtable4 ON table1.ABCD = table4.CDEF LEFT OUTER JOINtable5 ON table1.ABCD = table5.DEFG LEFT OUTER JOINtable2 ON table1.ABCD = table2.EFGHWHEREtable1.extractSession = ?AND table3.extractSession = ?AND table4.extractSession = ?AND table5.extractSession = ?AND table2.extractSession = ?

The correct query needs to be the following, but it won't work in the OLE DB Source:
SELECT table1.ABCD, table2.BAAA, table3.CAAA, table4.DAAA, table5.EAAAFROM table1LEFT OUTER JOINtable3 ON table1.ABCD = table3.BCDE AND table3.extractSession = ?LEFT OUTER JOINtable4 ON table1.ABCD = table4.CDEF AND table4.extractSession = ?LEFT OUTER JOINtable5 ON table1.ABCD = table5.DEFG AND table5.extractSession = ?LEFT OUTER JOINtable2 ON table1.ABCD = table2.EFGH AND table2.extractSession = ?WHEREtable1.extractSession = ?

=========================
ExtractSession is an integer that uniquely identifies the run (for the night, perhaps). I load a bunch of staging tables that retain their data for a period of time, with each load identified by this staging number. So, I need to restrict my data pull to the correct load (extractSession).

The first query returns three (3) rows when I should be getting back all 250,000 rows from table1. The second query listed works correctly.

Am I missing something, or do I need to find another way to constrain my tables' extract session dynamically at execution time in SSIS? Is a control table the best way to go here and simply join to it?

Thanks,
Phil

View 1 Replies View Related

Help With Reading Database.

Jun 29, 2005

I have this code that I hacked together from someone else's example.  I kind of understand how it works.  I just don't know if it will and i am not in a location right now to check.  I was wondering if I did this correctly first, second how can it improve and should i do something different.  Basically i just want to check the password in a database. I am passing the username and password to this function from another functioprivate bool authUser(string UserName, string Password){ string connectionString = ConfigurationSettings.AppSettings["DBConnectionString"];  SqlConnection DBConnection = new SqlConnection(connectionString);  bool result = false;  DBConnection.open() SqlCommand checkCommand = new SqlCommand("SELECT password FROM Users WHERE userName='" + Password + "', DBConnection) SqlDataReader checkDataReader = checkCommand.ExecuteReader();
 if(checkDataReader.GetString(0) == Password) {  result = true; } else {  result = false; } checkDataReader.Close(); DBConnection.Close();
 return result;}Thank you Buddy Lindsey

View 6 Replies View Related

Reading Database Question..

Mar 15, 2008

Hello all!

I am currently building a website and have reached a brickwall called SQL..

I hope this is ok to post on this forum I wasn't sure if I had come to the right place!

Basically I have an SQL database on my server and I would like to have my website access it and update information on a page i.e. :

Item Name: Quantity Sold: Price:
T-shirt 50 $10
Jeans 25 £20

How easy is such a thing to do as I have a very limited knowledge of SQL and especially incorporating it into web code..

Thanks!

jake

View 2 Replies View Related

Reading Blob From Sql Server Database

Jul 7, 2006

Hello,
I could save the file in the sql server database. The problem i am having is, I am not able to read the document from the database. I do not want to use response.outputstream......
I have to read the file for specific contents. Anyhelp would be great.
- Suresh
 

View 2 Replies View Related

Connecting To And Reading Data From A SQL Database

Jul 25, 2006

Hi Everyone,
I am looking for some help, as i am pulling my hair out looking for information.
I have been using asp for many years and am now starting to learn .net. so far so good....
I am now wanted to connect to a database, execute a simple select statement and then read/write the information out. I can't help but think in old asp code and i am having a hard time finding what i need to perfom this simple task.
I have used the grid controls etc, and these are very good - however, i need to connect to a database in the code-behind file and perfom various functions in the background.
If any of you could be so kind as to perhaps show me some demo code i would be grateful.
I would like to do:
A) Connect to a database (sql server 2000)B) Execute a simple SQL select statementC) Read the returned informationD) put this information into variables used elsewhereE) how do you check if no records are returned? such as the .EOF in asp?
Many thanks
Darren
 
 

View 1 Replies View Related

Reading Image From SQL 2000 Database

Aug 25, 2007

I am able to upload a jpeg to a sql 2000 database into a column called graphic, the datatype is an image. for some reason i can read the image and have it displayed! this is driving me insane. any help would be greatly appreciated. here is the code to upload. and below that is the code to display the image.UPLOAD CODE        If Not IsNothing(txtfileupload.PostedFile) Then            'Determine File Type            Dim strExtension As String = Path.GetExtension(txtfileupload.PostedFile.FileName).ToLower()            Dim strContentType As String = Nothing            Select Case strExtension                Case ".gif"                    strContentType = "image/gif"                Case ".jpg", ".jpeg", ".jpe"                    strContentType = "image/jpeg"                Case ".png"                    strContentType = "image/png"            End Select                  'Load FileUpload's InputStream into Byte array            Dim imageBytes(txtfileupload.PostedFile.InputStream.Length) As Byte            txtfileupload.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)                                    'INSERT DATA INTO DATABASE            Dim objSQLConn As SqlConnection            Dim strSQL As SqlCommand            objSQLConn = New SqlConnection("server=srvdb1.rrg.local;uid=rsusr;pwd=Letmein123;database=rsdb")            strSQL = New SqlCommand("insert into rsdata (graphic,contenttype,fname,lname,nname) values(@graphic,@contenttype,@fname,@lname,@nname)", objSQLConn)                strSQL.Parameters.AddWithValue("@graphic", imageBytes)            strSQL.Parameters.AddWithValue("@contenttype", strContentType)            strSQL.Parameters.AddWithValue("@fname", txtfname.Text)            strSQL.Parameters.AddWithValue("@lname", txtlname.Text)            strSQL.Parameters.AddWithValue("@nname", txtnname.Text)            objSQLConn.Open()            strSQL.ExecuteNonQuery()            objSQLConn.Close()                lblStatus.Text = "Records uploaded"        End If  CODE TO DISPLAY    Dim objSQLConn As SqlConnection    Dim strSQL As SqlCommand    Dim objSQLDataReader As SqlDataReader        objSQLConn = New SqlConnection("server=srvdb1.rrg.local;uid=rsusr;pwd=Letmein123;database=rsdb")    objSQLConn.Open()    strSQL = New SqlCommand("select graphic, contenttype from rsdata", objSQLConn)    objSQLDataReader = strSQL.ExecuteReader()While objSQLDataReader.Read()        Response.ContentType = objSQLDataReader("contenttype")        Response.BinaryWrite(objSQLDataReader("graphic"))End While        objSQLDataReader.Close()    objSQLConn.Close()%>

View 1 Replies View Related

Okay With Reading, But Problems With Updating The Database

Feb 20, 2008

Hello,I'm successfully using SqlDatSource to read data from SQL Server on a networked machine. Obviously I'd like to be able to update, edit or delete data, but the 'Advanced Sql Generation Options' in the SqlDatSource are greyed out.The result is that when I try and edit, update or delete I get this message Updating is not supported by data source 'SqlDataSourceDetails' unless
UpdateCommand is specified. Which makes sense because the options havn't been specified.I'm thinking this is probably a server side permissions issue but I've been through everything I can see and am now basically stuck.Any help would be appreciated  Many thanks 

View 7 Replies View Related

Timeout Expired While Reading From Database

Mar 27, 2008

Hi all I've a page which shows data (25-30 entries) that are retrieved by an SqlDataSource. The query is very simple since i don't have to join any table.unfortunately sometimes I get the following error message. It's strange, since the page often works fine but the error occurs a couple of times per day.Who has an idea of how I could solve this problem?
 
Server Error in '/' Application.

View 33 Replies View Related

Reading Or Writing A File To A SQL Database

Nov 22, 2004

Halo, I am a bit new to this
Please can someone help me, I would like to write a file(Any type) to a SQL database like a attached document(s) for the current record and be able to detatch the document when needed.
I use VB.NET for a ASP.NET app.
I basicly would like to attach documents to a piece of equipment may it be any kind and if the user views the equipment he will be able to detatch the documents for that piece of equipment and open it with the correct software.
PLEASE HELP!!!!!!!

View 1 Replies View Related

Arabic Language Not Reading In My Database

Nov 11, 2005

Hi i use sql server 2000 and i found problem in my database that is
when i write arabic language and closing my table and open it again i found all my data like question mark.
what can i do to save my data with arabic language.
note i use windows 2000 server.

View 1 Replies View Related

Problems Reading Data From A Database

Mar 24, 2008

I have a database that contains news items. There's a column that contains the actual article. In that field, there are paragraphs with page breaks. The page breaks in the database are represented as squares (unrecognizable characters I guess). When I try to read in the data, it doesn't recognize the page breaks, and it comes out all in one large paragraph. Is there any way to get around this?

View 2 Replies View Related

Reading/Writing Data From A SQL Database

Feb 14, 2008



Hi,
I have a data structure called 'Quote' which contains a number of different variables and controls ranging from text boxes, check boxes and radio buttons, i need to be able to read and write this from a database.

First I think a description of my overall project is needed:



Project Description
I have been given a brief that basically says: i have to create a programmed solution in VB to solve a problem. This problem can be anything we like, and I personally have chosen to create a program that manages quotes for building Log Cabins (this is very contrived and far from anything someone would do in the real world).

My solution will allow a generic user to create a quote (using a form with controls such as text boxes, check boxes, radio buttons) , and then save this to file. These users may then wish to load/edit this quote at a later date, from another form.

Whilst completing this project, i'll only have up to about 5 records (quotes) within the system, so i dont need the ability to store hundreds of records. And each record will be relatively short, with only about 10-15 data items within the data structure.

Also the Admin (or business owner in this case) need to be able to view all saved quotes in a presentable format, and edit them if needs be, from within this same program.

This solution does not need to be absolutely perfect and 100% efficiently coded, or have all the bells and whistles a real-world program would have. This is for an A level computing project by the way.





So basically, i need to be able to read from the database (to populate a Data Grid (i imagine this is best way?)) and so Admin can access any quote and edit it (editing is not vital, but viewing/printing is. Maybe i should stop at just viewing any quote?). Also i need generic users to be able to fill in the Edit Quote form and then save this data into the database.

And is a data structure really required for me to use a database?

I've never used databases in VB before (but have used them elsewhere, mainly Access) and so am completely new to this. Any help will be much appreciated.
Thanks

View 13 Replies View Related

Reading Data From A String Into A SQL Database

Jan 18, 2007

Hi, i'm writing a SOCKET Port Listener for a Database, it must be multi-threaded and listen on a port for a record that when it comes in, it must write the record to the SQL database (MS SQL Server). I've got the listener to read the data over the port already and write the record into a string which i have already sliced up. Now i need to create a connection to the database and insert the variables into the database.

If Someone will please be able to give me a rough idea of how i could accomplish this with some sample code, then i will be greatful, i'm new to C#, but here is my code that i have so far.

//This is the Connection that i have made and where i am currently stuck, i dunno how to go further. Any help will be welcome.

public class ConnectionToMSDatabase
{
public void InsertDataIntoDatabase(string TableName, string connectionString, string dataFields)
{
string InsertSQLStatement;
InsertSQLStatement = "INSERT INTO " + TableName + " VALUES (" + dataFields + ")";

OleDbConnection ConnectionToDatabase = new OleDbConnection(connectionString);
ConnectionToDatabase.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = ConnectionToDatabase;
command.CommandText = InsertSQLStatement;
command.ExecuteNonQuery();
command.Connection.Close();
}
}


//Here is my connection string, all the retrieved data is stored in a string array call fullRecord

ConnectionStringToDatabase = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=" +
"Administrator" + ";Initial Catalog=FORGE;Data Source=FORGE";

View 4 Replies View Related

Reading Data From Text File Database

Jun 6, 2007

 Hi everyone I have a directory that contains a lot of text files that have data I need to draw from.  I want to know if it is possible to write a program that will read all of the text files in the directory and pull out data and save it to a new textfile. For example: Each text file is formatted this wayColumn1, Column2, Column3"1","xxxx","yyyy""2", "xxxx", "yyyy""3", "XXXX", "yyyy" I want to put all lines that begin with 1 in one text file, all the lines that begin with two in another text file, and the same with all lines that begin with 3. my problem is I want to be able to point at the folder that contains those files and have it read every text file in the folder and perform the operation.  If this is possible can someone point me in the right direction on how to get started.Thank you for any help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 

View 1 Replies View Related

Invalid Object Name While Reading Data Out Of An SQL Database

Jan 4, 2006

Hi all,I'm a complete newbie on ASP.Net.I want to get some data out of a SQLserver Database running on my system with SQL Server 2005 Express. The name of the Database is 'tempdb' and the table is called "Members". the SQLServer runs as Local System with the Windows account.When I try to open the site, I always get the same error:Invalid object name 'Members'I don't know what to do anymore. I read a post, where anybody set the rights for the owner, but my database is running with the Windows account.Here is the Code of the page so far:<%@ Page Language="VB" Debug="True" Strict="True" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SQlClient" %><script runat="server">Sub Page_Load (ByVal Sender As Object, _ ByVal E As EventArgs) Dim connStr As String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" connStr += "database=tempdb;" connStr += "Truster_Connection=yes"
Dim conn As New SQLConnection(connStr) conn.Open() Dim sql As String sql = "SELECT COUNT (*) FROM Members" Dim cmd As New SQLCommand(sql, conn) Dim ergebnis As String ergebnis = cmd.ExecuteScalar().toString() Dim t As String t = "Die Tabelle Members hat " & _ ergebnis & " Zeilen. <br>" & _ "Das Kommando lautet: " & _ cmd.CommandText & "<br>" & _ "Der Kommandotyp ist: " & _ cmd.CommandType ausgabe.innerHTML = t End Sub</script><html><head><title>Demo zu SQLCommand.ExecuteScalar</title></head><body><h3>Demo zu SQLCommand.ExecuteScalar</h3><p runat="server" id="ausgabe" /></body></html>Thanks for your help an sorry for my english.GreetsFlash_Prince

View 4 Replies View Related

Reporting Services :: Unable To Show Images From Folder By Reading Path From Database In SSRS Report

Apr 28, 2015

Basically i have 3 images capacity per record in my asp.net application. In there i am saving the image path with record id in database and image in my application folder.

Now i am creating SSRS Report in Report builder . In there i have taken one image control to show the images. In the Image properties in report builder i have chosen database under the select the image source field. then inside use this field i have chosen image url and in use this MIME Type i have selected image/jpeg. Now i have saved this report in report server folder.

Now while calling in .net web from through report viewer control. It is opening the report but wont showing the image.

View 2 Replies View Related

Access Violation

Aug 22, 2001

How execption access violation error msg with severity 19 handled in sql7 ?

Thanks for info.

View 1 Replies View Related

DTS Integrity Violation

Jun 12, 2000

I having a problem importing a text file into an existing table using the DTS import wizard. The problem I am having is, I am getting an error message stating: Integrity violation: attempt to insert null data or data which violates constraints. The column the error is referenced to is an identity field and I am not trying to insert any data into the field. I have the allow insert identity box checked in the transformation section. Does anyone know about how to solve this problem.
Thanks
James

View 1 Replies View Related

Primary Key Violation When There Is Only One Row

Feb 23, 2000

I have a table with 5 columns .Length of the 2nd column is 4 characters.
I have to create a new database and copy the existing data.Alter the 2nd column to have 6 charactrers.
Append the values in 2nd column with 00.
I have only one row in the old database.
I am able to copy the rows.But after that when I try to update,it is giving primary key violation error.
What could be the reason?

View 1 Replies View Related

Access Violation

Oct 15, 2003

System Spec: OS = Windows 2000, SQL Server 7 SP4.

I'm getting the following error when I run a stored procedure which truncates a table then inserts data into it. There are no complex joins, order, group by or union clauses in the insert statement:

Error: 0, Severity: 19, State: 0
SqlDumpExceptionHandler: Process 17 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

I've read that this is fixed in SQL 7 SP2 but we're on SP4?? I have re-installed SQL SP4.

View 1 Replies View Related

Primary Key Violation ???????

Apr 8, 1999

I am running SQL 6.5 service pack 5a.

I keep getting a Attempt to insert duplicate key row in object... when I try to add a record. I know for a fact that the primary key is not being duplicated because I can look in the db and see that it is not there and if I continue to try to add it it will eventually succeed. Does anyone know what might be causing this?

Please email as well as post.

Thanks.
Carole

View 2 Replies View Related

Primary Key Violation

Jul 14, 2004

Hi,
I have got a very peculier kind of problem. My package is running on SQL 2000. There is a identity primary key in a table. Now when I submit the data from 2 different computer at the same time. Only one data is storing. The reason behind this is the primary key violation. as both the data are sending the request to the database at the same time.................n as the primary key is th identity column, it is storing one that value which is able to store the data at the forst hand.
Now plz help me out in this regard................. :confused:

View 11 Replies View Related

Anticipated PK Violation

Sep 6, 2004

I am maintaining a stored proc that does the following (pseudo code for simplicity)


INSERT INTO MyTable (CountColumn, ...) VALUES (1, ...)

-- 2627 = Primary key violation
IF (@@ERROR = 2627)
UPDATE MyTable SET CountColumn = CountColumn + 1
WHERE ...


Basically, try to create a new record with a PK and a count of 1. If a PK violation occurs, UPDATE the count of existing record.

Pretty simple logic. On some servers this works exactly as expected; the PK violation is caught and handled internally. On other servers, this error percolates out of the stored proc and causes the calling code to receive an error and fail. All servers are SQL Server 2000 SP3a Standard Edition. Any ideas why this happens?

Is there a better (and ideally as fast or faster) way to handle the INSERT/UPDATE issue? I can put the UPDATE first and INSERT if @@ROWCOUNT is 0, but that has the slight potential of a race condition where two processes try to INSERT the same PK at the same time.

View 5 Replies View Related

Violation Of Primary Key

Mar 30, 2008

Violation of PRIMARY KEY constraint 'PK_CUSTOM2'. Cannot insertduplicate key in object 'MHGROUP.Custom2'Is there ANY other reason this violation of the primary key wouldhappen OTHER than a trying to insert a duplicate record?This sql statement false due to the primary key violation:Insert Into MHGROUP.Custom2SelectClientNumber,MatterNumber,MatterDescription,'Y'From MG_EliteMatters EMLeft Outer Join MHGROUP.Custom2 C2On C2.CPARENT_ALIAS = EM.ClientNumberAnd C2.Custom_ALIAS = EM.MatterNumberWhere CPARENT_ALIAS Is Null And Custom_ALIAS Is Null---Custom2CREATE TABLE [MHGROUP].[CUSTOM2]([CPARENT_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNOT NULL,[CUSTOM_ALIAS] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NOTNULL,[C_DESCRIPT] [varchar](254) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[ENABLED] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,CONSTRAINT [PK_CUSTOM2] PRIMARY KEY CLUSTERED([CPARENT_ALIAS] ASC,[CUSTOM_ALIAS] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]--MG_EliteMattersCREATE TABLE [dbo].[MG_EliteMatters]([Matters] [varchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[ClientNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[ClientDescription] [varchar](254) COLLATESQL_Latin1_General_CP1_CI_AS NULL,[MatterNumber] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_ASNULL,[MatterDescription] [varchar](254) COLLATESQL_Latin1_General_CP1_CI_AS NULL,[LastDateModified] [datetime] NULL,[PracticeArea] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_ASNULL) ON [PRIMARY]

View 1 Replies View Related

Key Violation During Synchronization

Sep 10, 2006

Dear Friends

I restored same database in Publisher & subscriber.If I want to apply Transactional replication I have to apply initial snapshot.then I am getting key-violation problems during initialization .Some times Primary key table will be dropped before foreign key table.sometimes it won't able to drop some indexes.This I am getting if I am going for all tables of database.But here i need all tables.If I am going for selective table I don't have any problem.For avoiding this problem I tried all the options in table article option in publication wizard.But some na some key violation I am getting always.So please give me some better suggestion

Thanks in Advance

Filson

View 5 Replies View Related

Violation Of PRIMARY KEY

Sep 14, 2007

Jobs run at 1 am , sometimes fail with following error.

Violation of PRIMARY KEY constraint 'PK__xxxxx__300424B4'. Cannot insert duplicate key in object 'VW_xxxx . [SQLSTATE 23000] (Error 2627) The statement has been terminated. [SQLSTATE 01000] (Error 3621). The step failed.

when I am reruning 7 am job run successfully. Any advice will be great.

Thanks

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved