Showing posts with label records. Show all posts
Showing posts with label records. Show all posts

Monday, March 19, 2012

Cannot open database "database" requested by the login

We have a back end procedure that inserts/updates records in a table. Usually the upload file will have around 20k records. This procedure is called from our application which is designed using hibernate,struts.

Upload is getting completed. But after the upload is over and control goes to application code, we are again hitting the above table to get some details. Is this the root cause for the below issue?

This is what we get in application logs,

SQL Error: 4060, SQLState: S1000
2007-04-30 16:17:27,840 - ERROR [TP-Processor2] JDBCExceptionReporter.logExceptions(58) | Cannot open database "sdgebis" requested by the login. The login failed.
2007-04-30 16:17:27,840 - WARN [TP-Processor2] JDBCExceptionReporter.logExceptions(57) | SQL Error: 18456, SQLState: 28000
2007-04-30 16:17:27,840 - ERROR [TP-Processor2] JDBCExceptionReporter.logExceptions(58) | Login failed for user 'sa'.

2007-04-30 16:17:27,856 - WARN [TP-Processor2] SQLErrorCodeSQLExceptionTranslator.translate(279) | Unable to translate SQLException with errorCode '4060', will now try the fallback translator

What could be the reason for the above error?

Can anyone help me out please?Sounds like the two connections use different logins. And only one of them is mapped to a user in the database.

Thursday, March 8, 2012

Cannot limit results with ReportViewer

Hello,
I have been attempting to set up a report using the ReportViewer
control in VS2005. The report graphs the TOP X number of records based
on certain criteria. Naturally, I modified the report with a filter
for the TOP N results. This works, however, in the case of ties on the
last entry, all tied instances will get graphed. In my case, this may
be alot of entries causing the bar graph image to display unreadable
data since there are too many result to graph.
So, I attempted the following with no success since the server is SQL
2000 and not SQL 2005:
- Using the TOP keyword in the select query does not work with a
parameter (ie SELECT TOP @.rowcount FROM...) since I am using SQL 2000.
- I cannot use a stored procedure and use the "SET ROWCOUNT" command
with the select query.
- I cannot use the LIMIT keyword in SQL 2000.
Can anyone come up with a solution, other than upgrading to SQL 2005?
Thanks in advance,
Andrewcheck this one......
SELECT w1.CATEGORYID, w1.UNITSINSTOCK,COUNT(*) As Rank
FROM
(SELECT CATEGORYID, UNITSINSTOCK
FROM PRODUCTS
GROUP BY CATEGORYID, UNITSINSTOCK ) AS w1
INNER JOIN
(SELECT CATEGORYID, UNITSINSTOCK
FROM PRODUCTS
GROUP BY CATEGORYID, UNITSINSTOCK ) AS w2
ON w1.CATEGORYID = w2.CATEGORYID
AND w1.UNITSINSTOCK <= w2.UNITSINSTOCK
GROUP BY w1.CATEGORYID, w1.UNITSINSTOCK
HAVING COUNT(*) <=@.parameter
ORDER BY w1.CATEGORYID,w1.UNITSINSTOCK DESC
Regards
Dinesh
therealbigcoops@.gmail.com wrote:
> Hello,
> I have been attempting to set up a report using the ReportViewer
> control in VS2005. The report graphs the TOP X number of records based
> on certain criteria. Naturally, I modified the report with a filter
> for the TOP N results. This works, however, in the case of ties on the
> last entry, all tied instances will get graphed. In my case, this may
> be alot of entries causing the bar graph image to display unreadable
> data since there are too many result to graph.
> So, I attempted the following with no success since the server is SQL
> 2000 and not SQL 2005:
> - Using the TOP keyword in the select query does not work with a
> parameter (ie SELECT TOP @.rowcount FROM...) since I am using SQL 2000.
> - I cannot use a stored procedure and use the "SET ROWCOUNT" command
> with the select query.
> - I cannot use the LIMIT keyword in SQL 2000.
> Can anyone come up with a solution, other than upgrading to SQL 2005?
> Thanks in advance,
> Andrew

Friday, February 24, 2012

Cannot insert duplicate key row in object 'MSmerge_tombstone'

Hi,
I have made a replication since 2004-08-21. it works well, but recently i
got a problem. When i want to delete some records in a table, an error
occur. the message is:
Cannot insert duplicate key row in object 'MSmerge_tombstone' with unique
index 'uc1MSmerge_tombstone'
The statement has been terminated.
whatever how i do, even clear up all the records in table MSmerge_tombstone.
but when i try to delete the records in the table. i still got the error
message. i have searched more web pages for try to got some explain and
solution. but my work is useless. my boss is pressing me to solve this
problem in this week. Friends. Please help and save my life.
Regards
Jackson Chan
My personal opinion is that your unique index 'uc1MSmerge_tombstone' has gone
a bit funny.
Couple of sugestions, delete your unique index
run a checkdb on your database
Re-establish your index.
Peter
"We are all worms. But I believe that I am a glow-worm."
Winston Churchill
"Jackson BF" wrote:

> Hi,
> I have made a replication since 2004-08-21. it works well, but recently i
> got a problem. When i want to delete some records in a table, an error
> occur. the message is:
> Cannot insert duplicate key row in object 'MSmerge_tombstone' with unique
> index 'uc1MSmerge_tombstone'
> The statement has been terminated.
> whatever how i do, even clear up all the records in table MSmerge_tombstone.
> but when i try to delete the records in the table. i still got the error
> message. i have searched more web pages for try to got some explain and
> solution. but my work is useless. my boss is pressing me to solve this
> problem in this week. Friends. Please help and save my life.
> Regards
> Jackson Chan
>
>
>

Sunday, February 19, 2012

Cannot insert duplicate key

I am using SQL Server 2000. I have a table (tbDupes) with duplicate records. I want to populate another table (tbUnique) with unique records.

My tbDupes has about 50 columns and three of them make up my primary key in tbUnique. I thought I could get unique records by using the following SQL statement.

Code Snippet

INSERT INTO tbUnique

SELECT * FROM tbDupes

I received this error: Cannot insert duplicate key

Is there a database setting that will allow me to insert the first record and prevent any duplicates from being inserted? I thought this was the default behavior and think that maybe the DBA changed it.

I know I can achieve this by creating a cursor with tbDupes and then something like "IF NOT EXISTS(...) THEN INSERT". However, I would prefer to avoid using a cursor.

Try the below query,

INSERT INTO tbUnique

SELECT Distinct * FROM tbDupes

|||That will not work because my primary key is made up of 3 columns. The remaining 47 columns may make the record unique. However, I only want 1 record for each primary key.|||

Hi Danny,

Let us assume that the primary key is conformed by (c1, c2, c3), then you can use:

insert into dbo.t1(c1, ..., cn)

select a.c1, ..., a.cn

from dbo.t2 as a

where not exists (

select *

from dbo.t1 as b

where b.c1 = a.c1 and b.c2 = a.c2 and b.c3 = a.c3

)

AMB

|||

Ok. One simple & easy way is adding the identity column temporarily, fetch the data using the following query and drop the temp identity column from the table,

Code Snippet

Create Table #duplicates (

[ID1] int ,

[ID2] int ,

[ID3] int ,

[Name1] Varchar(100) ,

[Name2] Varchar(100)

);

Insert Into #duplicates Values('1','1','1','SQLServer','2000');

Insert Into #duplicates Values('1','1','1','SQLServer','2005');

Insert Into #duplicates Values('1','1','2','SQLServer','2005');

Insert Into #duplicates Values('1','1','2','.NET','1.1');

Insert Into #duplicates Values('1','1','3','.NET','1.1');

--Temp Identity Column

Alter table #duplicates add tempid int identity(1,1);

--Required Unique data

select data.id1,data.id2,data.id3,data.Name1,data.Name2 from #duplicates data

Join

(

Select id1, id2, id3, min(tempid) tempid from #duplicates

Group by id1, id2, id3

) required

On required.tempid = data.tempid

--Droping temp identity column

Alter table#duplicatesdrop column tempid

|||Manivannan & Hunchback, thank you for your help.