Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Wednesday, March 28, 2012

No help from the error messages

I am writing a tracking system. There is a table in the Sql Server 2000 database that contains a column for the user's ntid, the page they visited, the date of the last visit, a column each to track hits for the current year and a previous year column (basically for archiveing and reporting purposes), and 12 columns for hits per month (obviously, one per column). To record a hit, my unit determined we would only track one hit per day, so basically, there are 3 possible outcomes I needed to account for :

1) A user had never hit the page before, so I need to record the user's ID, the page they hit for the first time (since it won't exist yet), increment the year counter for that user on that page, and then determine what month column counter should be incremented as well.

2) A user had hit the page before, but not on this same day, so I need to update the row for that user on that page, changing the last visit field to reflect the current date, and icnrementing the appropriate counters.

3) A user had hit the page already on the same day, so basically, nothing should be changed whatsoever. No action should be taken.

I wrote a stored procedure to attempt to accomplish that logic, and though it's probably not very pretty, I was surprised at how few errors I got on my first Syntax check. Here's the stored procedure :

CREATE PROCEDURE sp_hitMe
@.ntid varchar(10),
@.page varchar(50),
@.thisHit datetime
AS
SET NOCOUNT ON

DECLARE @.tempDate datetime
DECLARE @.yearCount int
DECLARE @.monthCount int
DECLARE @.inMonth varchar(20)
DECLARE @.monthColumn varchar(10)
SET @.inMonth = DATENAME(mm, @.thisHit)
SET @.monthColumn =
CASE
WHEN @.inMonth = 'January' THEN 'hitsInJan'
WHEN @.inMonth = 'February' THEN 'hitsInFeb'
WHEN @.inMonth = 'March' THEN 'hitsInMar'
WHEN @.inMonth = 'April' THEN 'hitsInApr'
WHEN @.inMonth = 'May' THEN 'hitsInMay'
WHEN @.inMonth = 'June' THEN 'hitsInJun'
WHEN @.inMonth = 'July' THEN 'hitsInJul'
WHEN @.inMonth = 'August' THEN 'hitsInAug'
WHEN @.inMonth = 'September' THEN 'hitsInSep'
WHEN @.inMonth = 'October' THEN 'hitsInOct'
WHEN @.inMonth = 'November' THEN 'hitsInNov'
WHEN @.inMonth = 'December' THEN 'hitsInDec'
END

DECLARE @.insString varchar(500)
DECLARE @.updString varchar(500)
SET @.insString = 'INSERT INTO tblTracking (ntid, page, lastVisit, hitsThisYear, ' + @.monthColumn + ') VALUES (' + @.ntid + ', ' + @.page + ', ' + @.thisHit + ', 1, 1)'

if exists(select * from tblTracking where ntid = @.ntid and @.page = page)
begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
-- DO NOTHING!
end
else
begin
DECLARE @.theColumn varchar (100)
SET @.theColumn = 'SELECT ' + @.monthColumn + ' FROM tblTracking WHERE ntid = @.ntid AND @.page = page'
SET @.yearCount = (SELECT hitsThisYear FROM tblTracking WHERE ntid = @.ntid AND @.page = page) + 1
SET @.monthCount = (Exec @.theColumn)
SET @.monthCount = @.monthCount + 1
SET @.updString = 'UPDATE tblTracking SET lastVisit = ' + @.thisHit + ', hitsThisYear = ' + @.yearCount + ', ' + @.monthColumn + ' = ' + @.monthCount + ' WHERE ntid = @.ntid AND @.page = page'
Exec @.updString
end
end
else
begin
Exec @.insString
end
GO

And to my surprise, the only 3 errors I got were :

Server: Msg 156, Level 15, State 1, Procedure sp_hitMe, Line 39
Incorrect syntax near the keyword 'end'.
Server: Msg 156, Level 15, State 1, Procedure sp_hitMe, Line 45
Incorrect syntax near the keyword 'Exec'.
Server: Msg 156, Level 15, State 1, Procedure sp_hitMe, Line 50
Incorrect syntax near the keyword 'end'.

However, these are of course so vague as to be useless to me. What's wrong with the procedure? What have I missed?

At around line 33 I changed the --Do Nothing so that it actually declares something that is never used...

begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
-- DO NOTHING!
DECLARE @.theColumn1 varchar (100)
end
else

An alternative is finding out how to do something like an if not exists()

As far as the Exec, why don't you make @.theColumn a temporary table instead, and work with it that way? I don't know about using variables as tables, but you can do this easily with a temporary table.

|||

LD50:

At around line 33 I changed the --Do Nothing so that it actually declares something that is never used...

begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
-- DO NOTHING!
DECLARE @.theColumn1 varchar (100)
end
else

An alternative is finding out how to do something like an if not exists()

As far as the Exec, why don't you make @.theColumn a temporary table instead, and work with it that way? I don't know about using variables as tables, but you can do this easily with a temporary table.

That do nothing must actually have been a slightly larger error, because when I changed it to declare a small variable (basically a bit, just to avoid too much memory usage), 2 of the errors went away. I'm still having ti gripe at me about the Exec (@.theColumn) line. I don't think in this case a temporary table will do the trick only because I'm basically only trying to get one value, which is the current value of the month counter. Any other ideas?

|||

I'm not quite sure what you're trying to do, or what the column names in tbltracking are, so you'll have to modify this a bit. But it will compile.

if exists(select * from tblTracking where ntid = @.ntid and @.page = page)
begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
-- DO NOTHING!

DECLARE @.theColumn1 varchar (100)
end
else
begin
Create Table #theColumn (theColumn varchar (100))
Insert into #theColumn
Select monthname from tblTracking Where ntid = @.ntid and page = @.page
--SET @.theColumn = 'SELECT ' + @.monthColumn + ' FROM tblTracking WHERE ntid = @.ntid AND @.page = page'
SET @.yearCount = (SELECT hitsThisYear FROM tblTracking WHERE ntid = @.ntid AND @.page = page) + 1
SET @.monthCount = (Select Count(*) from #theColumn)
SET @.monthCount = @.monthCount + 1
SET @.updString = 'UPDATE tblTracking SET lastVisit = ' + @.thisHit + ', hitsThisYear = ' + @.yearCount + ', ' + @.monthColumn + ' = ' + @.monthCount + ' WHERE ntid = @.ntid AND @.page = page'
Exec @.updString
end
end
else

|||

LD50:

An alternative is finding out how to do something like an if not exists()

That's exactly how you do it. IF NOT EXISTS(SELECT ...)

|||

Oh, THANK you! I did have to slightly modify what you put in there, but you had the gist of it, so that's awesome. I would go ahead and mark an answer here, and I probably will since you answered that concern, but I was testing the logic, and trying to input the same record twice, which should have simply done nothing, but instead it inserted a duplicate record. Any idea why the logic failed me there?

|||

well why don't you paste up your new code and we'll let you know...

A good troubleshooting tip is to add some select statements in each part of the if. That way you can run it and see which if statement is firing and/or see if the columns in the table contain the data you expect.

Example:

if exists(select * from tblTracking where ntid = @.ntid and @.page = page)
begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
-- DO NOTHING!
select * from tblTracking where lastVisit = @.thisHit
DECLARE @.theColumn1 varchar (100)
end
else
begin

select * from tblTracking

Create Table #theColumn (theColumn varchar (100))
Insert into #theColumn
Select monthname from tblTracking Where ntid = @.ntid and page = @.page
--SET @.theColumn = 'SELECT ' + @.monthColumn + ' FROM tblTracking WHERE ntid = @.ntid AND @.page = page'
SET @.yearCount = (SELECT hitsThisYear FROM tblTracking WHERE ntid = @.ntid AND @.page = page) + 1
SET @.monthCount = (Select Count(*) from #theColumn)
SET @.monthCount = @.monthCount + 1
SET @.updString = 'UPDATE tblTracking SET lastVisit = ' + @.thisHit + ', hitsThisYear = ' + @.yearCount + ', ' + @.monthColumn + ' = ' + @.monthCount + ' WHERE ntid = @.ntid AND @.page = page'
Exec @.updString
end
end
else
begin
select * from tblTracking
Exec @.insString
end

|||

I also noticed that your if is illogical

if exists(select * from tblTracking where ntid = @.ntid and @.page = page)

should be:

if exists(select * from tblTracking where ntid = @.ntid and page = @.page)

|||

LD50:

I also noticed that your if is illogical

if exists(select * from tblTracking where ntid = @.ntid and @.page = page)

should be:

if exists(select * from tblTracking where ntid = @.ntid and page = @.page)

Actually, I noticed that myself and had already corrected it... *sheepish shrug*

OK, well I've added in a SELECT statement for the 'do-nothing' branch of logic and changed the two Exec statements to Print statements so I don't get a ton of duplicate records. But the logic is still somehow faulty, as I'm using the Query Analyzer to test it, and trying to input the same record that already exists in the table still prints out the INSERT string, instead of the do-nothing SELECT statement. Here's what I have now, see if you can help me figure out what the problem is...

CREATE PROCEDURE sp_hitMe
@.ntid varchar(10),
@.page varchar(50),
@.thisHit smalldatetime
AS
SET NOCOUNT ON

DECLARE @.yearCount int
DECLARE @.monthCount int
DECLARE @.inMonth varchar(20)
DECLARE @.monthColumn varchar(10)
SET @.inMonth = DATENAME(mm, @.thisHit)
SET @.monthColumn =
CASE
WHEN @.inMonth = 'January' THEN 'hitsInJan'
WHEN @.inMonth = 'February' THEN 'hitsInFeb'
WHEN @.inMonth = 'March' THEN 'hitsInMar'
WHEN @.inMonth = 'April' THEN 'hitsInApr'
WHEN @.inMonth = 'May' THEN 'hitsInMay'
WHEN @.inMonth = 'June' THEN 'hitsInJun'
WHEN @.inMonth = 'July' THEN 'hitsInJul'
WHEN @.inMonth = 'August' THEN 'hitsInAug'
WHEN @.inMonth = 'September' THEN 'hitsInSep'
WHEN @.inMonth = 'October' THEN 'hitsInOct'
WHEN @.inMonth = 'November' THEN 'hitsInNov'
WHEN @.inMonth = 'December' THEN 'hitsInDec'
END

DECLARE @.insString varchar(500)
DECLARE @.updString varchar(500)
SET @.insString = 'INSERT INTO tblTracking(ntid, page, lastVisit, hitsThisYear, ' + @.monthColumn + ') VALUES (''' + @.ntid + ''','' ' + @.page + ''', ''' + Convert(varchar(15), @.thisHit, 101) + ''', ''1'', ''1'')'

if exists(select * from tblTracking where ntid = @.ntid and page = @.page)
begin
if exists(select * from tblTracking where lastVisit = @.thisHit)
begin
DECLARE @.bs bit
SELECT * FROM tblTracking where lastVisit = @.thisHit
end
else
begin
DECLARE @.theString varchar (100)
SET @.theString = 'SELECT ' + @.monthColumn + ' FROM tblTracking WHERE ntid = @.ntid AND page = @.page'
CREATE TABLE #theColumn (theColumn varchar (100))
INSERT INTO #theColumn
Exec @.theString
SET @.yearCount = (SELECT hitsThisYear FROM tblTracking WHERE ntid = @.ntid AND page = @.page) + 1
SET @.monthCount = (SELECT theColumn FROM #theColumn)
SET @.monthCount = @.monthCount + 1
SET @.updString = 'UPDATE tblTracking SET lastVisit = ' + Convert(varchar(15), @.thisHit, 101) + ', hitsThisYear = ' + @.yearCount + ', ' + @.monthColumn + ' = ' + @.monthCount + ' WHERE ntid = @.ntid AND page = @.page'
Print @.updString
end
end
else
begin
Print (@.insString)
end
GO

|||

Woo! Nevermind, I have finally figured it out. Turns out I needed to use LIKEs instead of =s when I was comparing the varchar values, and I needed to throw in some CASTs to turn some of the ints into varchars for the UPDATE string. If anyone cares to see the corrected, working code, I will post it, but it is working now.

Thanks for the help!

Monday, March 26, 2012

No duplicates exist but get Msg 2627, Cannot insert duplicate key in object

On SQL Server 2000, a transaction of thousands of INSERTs contains these three consecutive INSERT statements:

INSERT INTO PARAMETER_ATTRIBUTES (ID, MIN_VALUE, MAX_VALUE)
VALUES ('05b3b88a-f0f2-4e7e-a82f-73a7bd177a96', 0, 1)

INSERT INTO PARAMETER_ATTRIBUTES (ID, MIN_VALUE, MAX_VALUE)
VALUES ('05e51bee-ac3b-4257-90f1-f34adcb185cb', 0, 128)

INSERT INTO PARAMETER_ATTRIBUTES (ID, MIN_VALUE, MAX_VALUE)
VALUES ('05f33ded-979b-41ee-9d6c-ac5adc4d8635', -1000000000, 1000000000)

The transaction fails with a Msg 2627 error, Violation of PRIMARY KEY constraint 'ARR_Constraint2'. Cannot insert duplicate key in object 'PARAMETER_ATTRIBUTES'. SQL Profiler reveals that the last statement executed is the second INSERT.

The primary key is on the ID column. What is particularly significant is that before running the transaction, this query returns no rows:

select * from PARAMETER_ATTRIBUTES
where id in (
'05b3b88a-f0f2-4e7e-a82f-73a7bd177a96', -- pk value in first insert
'05e51bee-ac3b-4257-90f1-f34adcb185cb', -- pk value in second insert
'05f33ded-979b-41ee-9d6c-ac5adc4d8635') -- pk value in third insert

In other words, all three INSERTs contain primary key values that do not exist in the table. As you can see, each INSERT is inserting a unique value for the primary key. I am asserting that there are no duplicates. How can the fact of a Msg 2627 error be reconciled with the facts of no duplicates? Can SQL Profiler not be trusted to show the specific statement causing a duplicate key problem? In other words, in a transaction of 1000s of statements, does a dup key problem cause SQL Profiler to stop before it displays the statement causing the error?

Is there, by any chance, a trigger involved?

It does not look, on the surface, that you can both get no results from the select and the duplicate error. Therefore, we need to question the assumptions. Make sure that you can make the select return results from a known existant string. You might put the select after each of the selects.

What datatype are you using for the id?

That is how I would approach the debugging.

|||

No triggers exist.

The id column, the primary key column, is a uniqueidentifier.

|||Can you run the insert with just those three statements? One of the other batch inserts earlier in the order could contain an id with the same value. What you really need to do is run the select... where id in.... right before the insert, then just don't insert any rows after the insert, and see if there were rows existing the moment before statement 2 is run.|||The id value only exists in that one INSERT statement. I suspect that the last INSERT shown in SQL Profiler is not the INSERT causing the problem.|||

Further testing reveals that the the duplicate key INSERT occurs 100s of lines before the last statement shown in SQL Profiler.

Here is a detailed explanation of what is happening:

1. A very popular and well regarded database update utility is being used to update 100s of very similar databases.

2. This vendor's product puts all of the 10,000s of statements in a single transaction.

3. Within the single transaction are many batches of statements.

4. Within a particular batch, there is a statement that causes a duplicate key error. Not on the QA database, not on the many real databases, just on one developer's database.

5. The last statement in the batch does not cause a duplicate key error. It was the statement I was looking at because it was the last one the SQL Profiler displayed. I also looked at the immediately preceding and following (first statement of next batch) INSERT statements. None of these statements could or did cause a duplicate key error.

What we can conclude from this is that depending on how statements are grouped and processed, the last statement displayed by SQL Profiler in an abort situation may not physically be anywhere near the statement actually causing the problem.

No data is displayed in a Report on Win98

Hi,

I have created an OCX control in VB6.0 that contains the crystal report viewer.

On development machine (i.e. Win2K), my OCX control shows the crystal report properly. But, when I install my application on the client machine (Win98) no data is displayed in the report.

I have created the report using ADO connection and I am using 'SetDataSource' method of report object to pass the recordset to the report.

I have installed Crystal Report Application on the client machine. Through crystal report application I could see the data in the report.

Can any one help me?

With regards,
PinakinI use CrystalRyport. I want to print records in the same line in succession, how do i do

Saturday, February 25, 2012

Newbie:preparation to reindex SQL db

Hello,
A third-party vendor tells me a SQL db contains various errors and suggests
that I 'reindex' the db.
I see that I can go to SQL Query Analyzer, pick the db I need and run
DBCC DBREINDEX
Question is this, what's the implication of running this without specifying
a specific table ? Is that alright run this on the 'entire' database ?> Question is this, what's the implication of running this without
> specifying
> a specific table ? Is that alright run this on the 'entire' database ?
How large is the database? What is your tolerance for downtime?
I would make a backup of the database, restore it on another server, and
test out the reindex there. Not only will you get an idea of time/CPU/I/O
requirements, you will also be able to test how your application(s) will
work against it during the reindexing of the tables.
My guess is that in the long run you'll want to break up the operation into
smaller chunks (e.g. one or two tables at a time). But it's tough to say
without more information specific to *your* environment. I know what I
can't do here in mine. :-)|||Hi,
DBCC DBREINDEX will recreate the Index, But for identifying errors you need
to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
Once you identify the errors you need to execute DBCC CHECKDB with
REPAIR_REBUILD to clear the errors.
DBCC DBREINDEX can be used to remove the fragmentation in your table and
this command will lock your table. Due to this you can execute this command
only offline. So check your vendor whether to exeecute DBCC CHECKDB or
REINDEX.
Thanks
Hari
SQL Server MVP
"Magoo" <magoo-nospam@.hotmail.com> wrote in message
news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> Hello,
> A third-party vendor tells me a SQL db contains various errors and
suggests
> that I 'reindex' the db.
> I see that I can go to SQL Query Analyzer, pick the db I need and run
> DBCC DBREINDEX
> Question is this, what's the implication of running this without
specifying
> a specific table ? Is that alright run this on the 'entire' database ?
>|||What errors exactly did this vendor say you had in the database?
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:udIZZpRUFHA.2124@.TK2MSFTNGP14.phx.gbl...
> Hi,
> DBCC DBREINDEX will recreate the Index, But for identifying errors you
need
> to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
> Once you identify the errors you need to execute DBCC CHECKDB with
> REPAIR_REBUILD to clear the errors.
> DBCC DBREINDEX can be used to remove the fragmentation in your table and
> this command will lock your table. Due to this you can execute this
command
> only offline. So check your vendor whether to exeecute DBCC CHECKDB or
> REINDEX.
> Thanks
> Hari
> SQL Server MVP
> "Magoo" <magoo-nospam@.hotmail.com> wrote in message
> news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> suggests
> specifying
>

Newbie:preparation to reindex SQL db

Hello,
A third-party vendor tells me a SQL db contains various errors and suggests
that I 'reindex' the db.
I see that I can go to SQL Query Analyzer, pick the db I need and run
DBCC DBREINDEX
Question is this, what's the implication of running this without specifying
a specific table ? Is that alright run this on the 'entire' database ?> Question is this, what's the implication of running this without
> specifying
> a specific table ? Is that alright run this on the 'entire' database ?
How large is the database? What is your tolerance for downtime?
I would make a backup of the database, restore it on another server, and
test out the reindex there. Not only will you get an idea of time/CPU/I/O
requirements, you will also be able to test how your application(s) will
work against it during the reindexing of the tables.
My guess is that in the long run you'll want to break up the operation into
smaller chunks (e.g. one or two tables at a time). But it's tough to say
without more information specific to *your* environment. I know what I
can't do here in mine. :-)|||Hi,
DBCC DBREINDEX will recreate the Index, But for identifying errors you need
to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
Once you identify the errors you need to execute DBCC CHECKDB with
REPAIR_REBUILD to clear the errors.
DBCC DBREINDEX can be used to remove the fragmentation in your table and
this command will lock your table. Due to this you can execute this command
only offline. So check your vendor whether to exeecute DBCC CHECKDB or
REINDEX.
Thanks
Hari
SQL Server MVP
"Magoo" <magoo-nospam@.hotmail.com> wrote in message
news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> Hello,
> A third-party vendor tells me a SQL db contains various errors and
suggests
> that I 'reindex' the db.
> I see that I can go to SQL Query Analyzer, pick the db I need and run
> DBCC DBREINDEX
> Question is this, what's the implication of running this without
specifying
> a specific table ? Is that alright run this on the 'entire' database ?
>|||What errors exactly did this vendor say you had in the database?
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:udIZZpRUFHA.2124@.TK2MSFTNGP14.phx.gbl...
> Hi,
> DBCC DBREINDEX will recreate the Index, But for identifying errors you
need
> to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
> Once you identify the errors you need to execute DBCC CHECKDB with
> REPAIR_REBUILD to clear the errors.
> DBCC DBREINDEX can be used to remove the fragmentation in your table and
> this command will lock your table. Due to this you can execute this
command
> only offline. So check your vendor whether to exeecute DBCC CHECKDB or
> REINDEX.
> Thanks
> Hari
> SQL Server MVP
> "Magoo" <magoo-nospam@.hotmail.com> wrote in message
> news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> > A third-party vendor tells me a SQL db contains various errors and
> suggests
> > that I 'reindex' the db.
> >
> > I see that I can go to SQL Query Analyzer, pick the db I need and run
> > DBCC DBREINDEX
> >
> > Question is this, what's the implication of running this without
> specifying
> > a specific table ? Is that alright run this on the 'entire' database ?
> >
> >
>

Newbie:preparation to reindex SQL db

Hello,
A third-party vendor tells me a SQL db contains various errors and suggests
that I 'reindex' the db.
I see that I can go to SQL Query Analyzer, pick the db I need and run
DBCC DBREINDEX
Question is this, what's the implication of running this without specifying
a specific table ? Is that alright run this on the 'entire' database ?
> Question is this, what's the implication of running this without
> specifying
> a specific table ? Is that alright run this on the 'entire' database ?
How large is the database? What is your tolerance for downtime?
I would make a backup of the database, restore it on another server, and
test out the reindex there. Not only will you get an idea of time/CPU/I/O
requirements, you will also be able to test how your application(s) will
work against it during the reindexing of the tables.
My guess is that in the long run you'll want to break up the operation into
smaller chunks (e.g. one or two tables at a time). But it's tough to say
without more information specific to *your* environment. I know what I
can't do here in mine. :-)
|||Hi,
DBCC DBREINDEX will recreate the Index, But for identifying errors you need
to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
Once you identify the errors you need to execute DBCC CHECKDB with
REPAIR_REBUILD to clear the errors.
DBCC DBREINDEX can be used to remove the fragmentation in your table and
this command will lock your table. Due to this you can execute this command
only offline. So check your vendor whether to exeecute DBCC CHECKDB or
REINDEX.
Thanks
Hari
SQL Server MVP
"Magoo" <magoo-nospam@.hotmail.com> wrote in message
news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> Hello,
> A third-party vendor tells me a SQL db contains various errors and
suggests
> that I 'reindex' the db.
> I see that I can go to SQL Query Analyzer, pick the db I need and run
> DBCC DBREINDEX
> Question is this, what's the implication of running this without
specifying
> a specific table ? Is that alright run this on the 'entire' database ?
>
|||What errors exactly did this vendor say you had in the database?
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:udIZZpRUFHA.2124@.TK2MSFTNGP14.phx.gbl...
> Hi,
> DBCC DBREINDEX will recreate the Index, But for identifying errors you
need
> to execute either DBCC CHECKDB or DBCC CHECKTABLE commands.
> Once you identify the errors you need to execute DBCC CHECKDB with
> REPAIR_REBUILD to clear the errors.
> DBCC DBREINDEX can be used to remove the fragmentation in your table and
> this command will lock your table. Due to this you can execute this
command
> only offline. So check your vendor whether to exeecute DBCC CHECKDB or
> REINDEX.
> Thanks
> Hari
> SQL Server MVP
> "Magoo" <magoo-nospam@.hotmail.com> wrote in message
> news:usGs49MUFHA.3280@.TK2MSFTNGP09.phx.gbl...
> suggests
> specifying
>