Connecting Tech Pros Worldwide Forums | Help | Site Map

problem with MS sql server 2000 database table

Member
 
Join Date: Sep 2007
Posts: 109
#1: Jul 16 '08
Hi you all experts,

Here, I am running into strenge situation. I have ms sql server 2000 database and one of the table is acting strenge. I have trigger placed on this table to move data to the other table witin same database after validating the data.

data goes to the first table through my smart phone using sync process.

well at some point of time that table look likes locking up and no data can make it the table. after i delete data from the first table it starts working again.

Can any one help me firgure it our why it is happening or what should I do to prevent this?

Please it is very urgent and I am having no luck on solving this.

so, please please help.

Thank You,

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jul 16 '08

re: problem with MS sql server 2000 database table


Check your trigger. It might be recursing. Also, you don't want to execute a full table update or full table scan command on your trigger.

What's the size of your table?

-- CK
Member
 
Join Date: Sep 2007
Posts: 109
#3: Jul 18 '08

re: problem with MS sql server 2000 database table


Thank CK. I will check on my triggers. well at the moment my table has about 85 datafields.
and data i have is my test data about 2000 but it will grow once i solved this problem and launch this app.
Thank you,
Member
 
Join Date: Sep 2007
Posts: 109
#4: Jul 18 '08

re: problem with MS sql server 2000 database table


i can't figured it out so, here i am providing my trigger as well store procedure.

this is my trigger which is on table dbo.wrk
Expand|Select|Wrap|Line Numbers
  1. create trigger trigger_qcheck
  2. on [dbo].[Q_CHECK_WORK]
  3. for insert
  4. as
  5. exec [dbo].[SDFD_CheckAndLoad]
  6.  
once records gets into dbo.wrk this trigger fires up and moves data to dbo.glass by executing store procedure and here is the store procedure:

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE SDFD_CheckAndLoad
  2.  
  3. AS
  4.  
  5. BEGIN
  6.  
  7.             DECLARE @Id varchar(19)
  8.  
  9.             DECLARE @CBComplete varchar(1)
  10.  
  11.             DECLARE @PalmName varchar(20)
  12.  
  13.             DECLARE c5 CURSOR FOR
  14.  
  15.               SELECT [ID], CB_COMPLET, PALMNAME FROM dbo.Q_CHECK_WORK
  16.  
  17.               WHERE [ID] NOT IN (SELECT [ID] FROM dbo.Q_CHECK_GLASS)
  18.  
  19.             OPEN c5
  20.  
  21.             FETCH c5 INTO @Id, @CBComplete, @PalmName
  22.  
  23.  
  24.  
  25. print @id
  26.  
  27. print @CBComplete
  28.  
  29. print @PalmName
  30.  
  31.             WHILE @@FETCH_STATUS = 0
  32.  
  33.                BEGIN
  34.  
  35.               PRINT 'INSIDE WHILE'
  36.  
  37.                         IF @CBComplete='T'
  38.  
  39.                          BEGIN
  40.  
  41.                                     PRINT 'COMPARE'
  42.  
  43.                                     INSERT dbo.Q_CHECK_GLASS SELECT * FROM dbo.Q_CHECK_WORK WHERE [ID]=@Id
  44.  
  45.                                     /*delete from dbo.Q_CHECK_WORK WHERE [ID]=@Id*/
  46.  
  47.                                     PRINT 'AFTER INSERT'
  48.  
  49.                          END
  50.  
  51.                         ELSE
  52.  
  53.                                     INSERT dbo.Q_CHECK_FILTER values(@Id, @PalmName)
  54.  
  55.  
  56.  
  57.  
  58.  
  59.             FETCH NEXT FROM c5 INTO  @Id, @CBComplete, @PalmName
  60.  
  61.             END
  62.  
  63.             CLOSE c5
  64.  
  65.             DEALLOCATE c5
  66.  
  67. END
  68.  
  69. GO
  70.  
  71.  
Please help on solving this problem.

Thank You,
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#5: Jul 18 '08

re: problem with MS sql server 2000 database table


First, consider not using a cursor.

Second, the query

Expand|Select|Wrap|Line Numbers
  1. SELECT [ID], CB_COMPLET, PALMNAME FROM dbo.Q_CHECK_WORK
  2. WHERE [ID] NOT IN (SELECT [ID] FROM dbo.Q_CHECK_GLASS)
is still a full table scan. Consider using the logical inserted tables.

Read here for more info.

Happy coding!

-- CK
Reply