Showing posts with label primary. Show all posts
Showing posts with label primary. Show all posts

Tuesday, March 27, 2012

Error when shrinking data file in SQL 2005

Hi,
I got the same error,
When i moved all of user tables and indexes out of primary FG and to a new
FG, my Primary is left with around 17GB of which less than a 1GB is actually
used, and when I ran shrink file on the only file on that FG, it took ages.
then I stoped it (in 2000 it would have taken max 2-3 hours, our SAN is not
that bad :-) ). when I ran it again I get the error described.
when I back up the db and restore it, then I can shrink the file.
this is a db in simle mode, dev environment. worried what happens when we go
to production with this.
error:
File ID 1 of database ID X cannot be shrunk as it is either being shrunk by
another process or is empty.
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should
be discarded.
CTS DBA
"XNMB" wrote:

> i came accross this problem too. what did was to restart the service
> and executed dbcc shrinkfile again. that time it succeeded.
>
I tried detach and re-attach the database fie and run DBCC SHRINKFILE
But I wouldn't recommend shrinking. Here's an article by the great Tibor
Karaszi on database shrinking
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
"CTS_DBA" <CTSDBA@.discussions.microsoft.com> wrote in message
news:630320F3-22A4-4D33-A245-54D14D4784FD@.microsoft.com...[vbcol=seagreen]
> Hi,
> I got the same error,
> When i moved all of user tables and indexes out of primary FG and to a new
> FG, my Primary is left with around 17GB of which less than a 1GB is
> actually
> used, and when I ran shrink file on the only file on that FG, it took
> ages.
> then I stoped it (in 2000 it would have taken max 2-3 hours, our SAN is
> not
> that bad :-) ). when I ran it again I get the error described.
> when I back up the db and restore it, then I can shrink the file.
> this is a db in simle mode, dev environment. worried what happens when we
> go
> to production with this.
> error:
> File ID 1 of database ID X cannot be shrunk as it is either being shrunk
> by
> another process or is empty.
> Msg 0, Level 11, State 0, Line 0
> A severe error occurred on the current command. The results, if any,
> should
> be discarded.
> --
> CTS DBA
>
> "XNMB" wrote:
|||hi,
thanks for the reply.
I know what you mean, but what I don't understand is why shrinkfile wouldn't
work when there's so much free space in the file.
over 8GB
if the original database shrunk in SQL 2000 it works perfectly.
Thanks
CTS DBA
"bass_player [SBS-MVP]" wrote:

> I tried detach and re-attach the database fie and run DBCC SHRINKFILE
> But I wouldn't recommend shrinking. Here's an article by the great Tibor
> Karaszi on database shrinking
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp
> "CTS_DBA" <CTSDBA@.discussions.microsoft.com> wrote in message
> news:630320F3-22A4-4D33-A245-54D14D4784FD@.microsoft.com...
>
>

Friday, March 9, 2012

Error Violation of Primary Key While Attaching Database

Hello all,
I have been trying to attach a database but it fails because of
duplicate rows (Error 2627).
I searched in the Internet for removing duplicate records but it can
only work if I manage to attach the database first (correct me if I'm
wrong). So without having the database attached to the SQL server, I
will not manage to remove the duplicate rows. But when I tried to
attach, it checks for duplicate records automatically and fail to
attach.
Is there any workaround for my case?
Thanks in advance.
Regards,
Garreth Goh
BTW, it is SQL 2000 with SP3.
Regards,
Garreth Goh
On Dec 18, 10:02 am, gohtiamt...@.gmail.com wrote:
> Hello all,
> I have been trying to attach a database but it fails because of
> duplicate rows (Error 2627).
> I searched in the Internet for removing duplicate records but it can
> only work if I manage to attach the database first (correct me if I'm
> wrong). So without having the database attached to the SQL server, I
> will not manage to remove the duplicate rows. But when I tried to
> attach, it checks for duplicate records automatically and fail to
> attach.
> Is there any workaround for my case?
> Thanks in advance.
> Regards,
> Garreth Goh
|||Hi,
More updates after several attempts (with separate SQL server 2000
SP4).
01. I move the MDF and LDF files to another folders. I have two MDF
and two LDF files for one database.
02. I attach the same but blank backup database to my SQL server with
a new database name.
03. Back it up.
04. Restore the backup with the original database name in the initial
folder where the corrupted files were.
05. Detach the new restored (but empty) database.
06. Move the new created MDF and LDF files to another folder.
07. Copy the original corrupted MDF and LDF files back to the original
folder.
08. Attach the database. Got "Suspect" message.
09. Update "sysdatabases" to set the database into Emergency Mode.
10. Attach the database back. I got Emergency Mode.
11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
"REPAIR_ALLOW_DATA_LOSS".
12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
it tells me to have Single-User mode when trying to run "DBCC
CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
database 'MyDB' because the database is in bypass recovery mode."
I am stuck here. Could anyone here help, please?
I may have incorrectly listed down the sequence from point 8 to 11 but
my current status is at point 13.
Regards,
Garreth Goh
On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:
> BTW, it is SQL 2000 with SP3.
> Regards,
> Garreth Goh
|||Or get Microsoft Technical Support on the phone.
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
kgboles a earthlink dt net
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:261F6FD2-B073-42F2-A218-B3B6AFE3750D@.microsoft.com...
> The error pretty much speak for itself. My guess is that you have to try
> to export the data to a clean database, using some combination of script
> objects (unless you have DDL files to re-create them) and for the data
> SELECT INTO., INSERT SELECT, BCP etc.
> I would bring in an expert if above doesn't feel comfortable to you...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> <gohtiamtjai@.gmail.com> wrote in message
> news:078e33bc-1d03-4d24-a65b-96367d382dde@.a35g2000prf.googlegroups.com...
>

Error Violation of Primary Key While Attaching Database

Hello all,
I have been trying to attach a database but it fails because of
duplicate rows (Error 2627).
I searched in the Internet for removing duplicate records but it can
only work if I manage to attach the database first (correct me if I'm
wrong). So without having the database attached to the SQL server, I
will not manage to remove the duplicate rows. But when I tried to
attach, it checks for duplicate records automatically and fail to
attach.
Is there any workaround for my case?
Thanks in advance.
Regards,
Garreth GohBTW, it is SQL 2000 with SP3.
Regards,
Garreth Goh
On Dec 18, 10:02 am, gohtiamt...@.gmail.com wrote:
> Hello all,
> I have been trying to attach a database but it fails because of
> duplicate rows (Error 2627).
> I searched in the Internet for removing duplicate records but it can
> only work if I manage to attach the database first (correct me if I'm
> wrong). So without having the database attached to the SQL server, I
> will not manage to remove the duplicate rows. But when I tried to
> attach, it checks for duplicate records automatically and fail to
> attach.
> Is there any workaround for my case?
> Thanks in advance.
> Regards,
> Garreth Goh|||Hi,
More updates after several attempts (with separate SQL server 2000
SP4).
01. I move the MDF and LDF files to another folders. I have two MDF
and two LDF files for one database.
02. I attach the same but blank backup database to my SQL server with
a new database name.
03. Back it up.
04. Restore the backup with the original database name in the initial
folder where the corrupted files were.
05. Detach the new restored (but empty) database.
06. Move the new created MDF and LDF files to another folder.
07. Copy the original corrupted MDF and LDF files back to the original
folder.
08. Attach the database. Got "Suspect" message.
09. Update "sysdatabases" to set the database into Emergency Mode.
10. Attach the database back. I got Emergency Mode.
11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
"REPAIR_ALLOW_DATA_LOSS".
12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
it tells me to have Single-User mode when trying to run "DBCC
CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
database 'MyDB' because the database is in bypass recovery mode."
I am stuck here. Could anyone here help, please?
I may have incorrectly listed down the sequence from point 8 to 11 but
my current status is at point 13.
Regards,
Garreth Goh
On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:
> BTW, it is SQL 2000 with SP3.
> Regards,
> Garreth Goh|||The error pretty much speak for itself. My guess is that you have to try to
export the data to a
clean database, using some combination of script objects (unless you have DD
L files to re-create
them) and for the data SELECT INTO., INSERT SELECT, BCP etc.
I would bring in an expert if above doesn't feel comfortable to you...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<gohtiamtjai@.gmail.com> wrote in message
news:078e33bc-1d03-4d24-a65b-96367d382dde@.a35g2000prf.googlegroups.com...[vbcol=seagreen]
> Hi,
> More updates after several attempts (with separate SQL server 2000
> SP4).
> 01. I move the MDF and LDF files to another folders. I have two MDF
> and two LDF files for one database.
> 02. I attach the same but blank backup database to my SQL server with
> a new database name.
> 03. Back it up.
> 04. Restore the backup with the original database name in the initial
> folder where the corrupted files were.
> 05. Detach the new restored (but empty) database.
> 06. Move the new created MDF and LDF files to another folder.
> 07. Copy the original corrupted MDF and LDF files back to the original
> folder.
> 08. Attach the database. Got "Suspect" message.
> 09. Update "sysdatabases" to set the database into Emergency Mode.
> 10. Attach the database back. I got Emergency Mode.
> 11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
> "REPAIR_ALLOW_DATA_LOSS".
> 12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
> it tells me to have Single-User mode when trying to run "DBCC
> CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
> 13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
> this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
> database 'MyDB' because the database is in bypass recovery mode."
> I am stuck here. Could anyone here help, please?
> I may have incorrectly listed down the sequence from point 8 to 11 but
> my current status is at point 13.
>
> Regards,
> Garreth Goh
>
> On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:|||Or get Microsoft Technical Support on the phone.
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
kgboles a earthlink dt net
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:261F6FD2-B073-42F2-A218-B3B6AFE3750D@.microsoft.com...
> The error pretty much speak for itself. My guess is that you have to try
> to export the data to a clean database, using some combination of script
> objects (unless you have DDL files to re-create them) and for the data
> SELECT INTO., INSERT SELECT, BCP etc.
> I would bring in an expert if above doesn't feel comfortable to you...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> <gohtiamtjai@.gmail.com> wrote in message
> news:078e33bc-1d03-4d24-a65b-96367d382dde@.a35g2000prf.googlegroups.com...
>

Error Violation of Primary Key While Attaching Database

Hello all,
I have been trying to attach a database but it fails because of
duplicate rows (Error 2627).
I searched in the Internet for removing duplicate records but it can
only work if I manage to attach the database first (correct me if I'm
wrong). So without having the database attached to the SQL server, I
will not manage to remove the duplicate rows. But when I tried to
attach, it checks for duplicate records automatically and fail to
attach.
Is there any workaround for my case?
Thanks in advance.
Regards,
Garreth GohBTW, it is SQL 2000 with SP3.
Regards,
Garreth Goh
On Dec 18, 10:02 am, gohtiamt...@.gmail.com wrote:
> Hello all,
> I have been trying to attach a database but it fails because of
> duplicate rows (Error 2627).
> I searched in the Internet for removing duplicate records but it can
> only work if I manage to attach the database first (correct me if I'm
> wrong). So without having the database attached to the SQL server, I
> will not manage to remove the duplicate rows. But when I tried to
> attach, it checks for duplicate records automatically and fail to
> attach.
> Is there any workaround for my case?
> Thanks in advance.
> Regards,
> Garreth Goh|||Hi,
More updates after several attempts (with separate SQL server 2000
SP4).
01. I move the MDF and LDF files to another folders. I have two MDF
and two LDF files for one database.
02. I attach the same but blank backup database to my SQL server with
a new database name.
03. Back it up.
04. Restore the backup with the original database name in the initial
folder where the corrupted files were.
05. Detach the new restored (but empty) database.
06. Move the new created MDF and LDF files to another folder.
07. Copy the original corrupted MDF and LDF files back to the original
folder.
08. Attach the database. Got "Suspect" message.
09. Update "sysdatabases" to set the database into Emergency Mode.
10. Attach the database back. I got Emergency Mode.
11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
"REPAIR_ALLOW_DATA_LOSS".
12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
it tells me to have Single-User mode when trying to run "DBCC
CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
database 'MyDB' because the database is in bypass recovery mode."
I am stuck here. Could anyone here help, please?
I may have incorrectly listed down the sequence from point 8 to 11 but
my current status is at point 13.
Regards,
Garreth Goh
On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:
> BTW, it is SQL 2000 with SP3.
> Regards,
> Garreth Goh|||The error pretty much speak for itself. My guess is that you have to try to export the data to a
clean database, using some combination of script objects (unless you have DDL files to re-create
them) and for the data SELECT INTO., INSERT SELECT, BCP etc.
I would bring in an expert if above doesn't feel comfortable to you...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
<gohtiamtjai@.gmail.com> wrote in message
news:078e33bc-1d03-4d24-a65b-96367d382dde@.a35g2000prf.googlegroups.com...
> Hi,
> More updates after several attempts (with separate SQL server 2000
> SP4).
> 01. I move the MDF and LDF files to another folders. I have two MDF
> and two LDF files for one database.
> 02. I attach the same but blank backup database to my SQL server with
> a new database name.
> 03. Back it up.
> 04. Restore the backup with the original database name in the initial
> folder where the corrupted files were.
> 05. Detach the new restored (but empty) database.
> 06. Move the new created MDF and LDF files to another folder.
> 07. Copy the original corrupted MDF and LDF files back to the original
> folder.
> 08. Attach the database. Got "Suspect" message.
> 09. Update "sysdatabases" to set the database into Emergency Mode.
> 10. Attach the database back. I got Emergency Mode.
> 11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
> "REPAIR_ALLOW_DATA_LOSS".
> 12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
> it tells me to have Single-User mode when trying to run "DBCC
> CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
> 13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
> this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
> database 'MyDB' because the database is in bypass recovery mode."
> I am stuck here. Could anyone here help, please?
> I may have incorrectly listed down the sequence from point 8 to 11 but
> my current status is at point 13.
>
> Regards,
> Garreth Goh
>
> On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:
>> BTW, it is SQL 2000 with SP3.
>> Regards,
>> Garreth Goh|||Or get Microsoft Technical Support on the phone.
--
Kevin G. Boles
TheSQLGuru
Indicium Resources, Inc.
kgboles a earthlink dt net
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:261F6FD2-B073-42F2-A218-B3B6AFE3750D@.microsoft.com...
> The error pretty much speak for itself. My guess is that you have to try
> to export the data to a clean database, using some combination of script
> objects (unless you have DDL files to re-create them) and for the data
> SELECT INTO., INSERT SELECT, BCP etc.
> I would bring in an expert if above doesn't feel comfortable to you...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> <gohtiamtjai@.gmail.com> wrote in message
> news:078e33bc-1d03-4d24-a65b-96367d382dde@.a35g2000prf.googlegroups.com...
>> Hi,
>> More updates after several attempts (with separate SQL server 2000
>> SP4).
>> 01. I move the MDF and LDF files to another folders. I have two MDF
>> and two LDF files for one database.
>> 02. I attach the same but blank backup database to my SQL server with
>> a new database name.
>> 03. Back it up.
>> 04. Restore the backup with the original database name in the initial
>> folder where the corrupted files were.
>> 05. Detach the new restored (but empty) database.
>> 06. Move the new created MDF and LDF files to another folder.
>> 07. Copy the original corrupted MDF and LDF files back to the original
>> folder.
>> 08. Attach the database. Got "Suspect" message.
>> 09. Update "sysdatabases" to set the database into Emergency Mode.
>> 10. Attach the database back. I got Emergency Mode.
>> 11. Run "DBCC CHECKDB WITH NO_INFOMSGS" tells me to do
>> "REPAIR_ALLOW_DATA_LOSS".
>> 12. Stop SQL services and run in Command Prompt "SQLSERVR -c -m" cause
>> it tells me to have Single-User mode when trying to run "DBCC
>> CHECKDB ...REPAIR_ALLOW_DATA_LOSS".
>> 13. When I try to run "DBCC CHECKDB ...REPAIR_ALLOW_DATA_LOSS" in
>> this Single-Mode, it tells me "Could not run BEGIN TRANSACTION in
>> database 'MyDB' because the database is in bypass recovery mode."
>> I am stuck here. Could anyone here help, please?
>> I may have incorrectly listed down the sequence from point 8 to 11 but
>> my current status is at point 13.
>>
>> Regards,
>> Garreth Goh
>>
>> On Dec 18, 10:58 am, gohtiamt...@.gmail.com wrote:
>> BTW, it is SQL 2000 with SP3.
>> Regards,
>> Garreth Goh
>

Friday, February 17, 2012

Error severity

Hi,
I want to write this SQL script
--
create table table1(
ID_TABLE1 varchar(15) not null
constraint PK_TABLE1 primary key clustered
(ID_TABLE1)
)
IF @.@.ERROR <> 0
BEGIN
print 'Error create table1'
END
--
The problem is when there is a 'create error', the code
print 'Error ...' is not executed because the error's
severity is too high and the script stops.
Is it possible to trap the default error ? When there is a
create error, I want that's the @.@.error is initialized and
the test is executed.
Thanks in advance for your help
Antoine (F-Paris)
MSSQL 7 & MSSQL 2000If the error is severe enough it will stop the batch and you can not trap it
within the batch. You would have to check for the error where you call the
batch. If your using something like ADO, sql server will report an error
that you can see in the errors collection.
Andrew J. Kelly
SQL Server MVP
"Antoine C." <acazedev@.libertysurfXXX.fr> wrote in message
news:11da01c3df60$d4f02bf0$a401280a@.phx.gbl...
quote:

> Hi,
> I want to write this SQL script
> --
> create table table1(
> ID_TABLE1 varchar(15) not null
> constraint PK_TABLE1 primary key clustered
> (ID_TABLE1)
> )
> IF @.@.ERROR <> 0
> BEGIN
> print 'Error create table1'
> END
> --
> The problem is when there is a 'create error', the code
> print 'Error ...' is not executed because the error's
> severity is too high and the script stops.
> Is it possible to trap the default error ? When there is a
> create error, I want that's the @.@.error is initialized and
> the test is executed.
> Thanks in advance for your help
> Antoine (F-Paris)
> MSSQL 7 & MSSQL 2000
|||
quote:

>--Original Message--
>If the error is severe enough it will stop the batch
> and you can not trap itwithin the batch.
> You would have to check for the error where you call the
>batch.
>--

Thank you for the quick answer Andrew.
Bye