Solved

SQL On Insert Trigger to update image field is limited to 50 characters?

Posted on 2009-03-31
2
300 Views
Last Modified: 2012-06-27
Hi. We are using Microsoft SQL Server 2000. The code below does work to update an image field in the Shipper table with the corresponding serial numbers, but when I tried a long list of serial numbers, I counted only 50 characters entered into the field.

What can I do to improve the trigger so all of the information can be entered?

Thanks.
CREATE   TRIGGER ABC_UPDATE_PACK_LIST_SN ON [dbo].[SHIPPER_LINE] 
FOR INSERT 
AS
 
                      DECLARE @ROWID		VARCHAR(15) 
	DECLARE @CUST_ORDER_ID	VARCHAR(10)
	DECLARE @CUST_ORDER_LINE	VARCHAR(2)
	DECLARE @APG_SERIAL_NUM	 VARCHAR(50)	
	DECLARE @LONG_DESC		VARCHAR(50)
	DECLARE @PACKLIST_ID		VARCHAR(10)
	DECLARE @PACKLIST_LINE	VARCHAR(4)
	
	
	SELECT @ROWID = I.ROWID, @CUST_ORDER_ID = I.CUST_ORDER_ID,
		@CUST_ORDER_LINE = I.CUST_ORDER_LINE_NO,
		@PACKLIST_ID = I.PACKLIST_ID, 
		@PACKLIST_LINE = I.LINE_NO
		FROM INSERTED I
 
	SELECT @ABC_SERIAL_NUM=ABCDE.dbo.ABC_SERIAL_NUMBERS.SERIAL_NUMBERS
	        FROM ABCDE.dbo.ABC_SERIAL_NUMBERS
		WHERE (@CUST_ORDER_ID = CUST_ORDER) AND (@CUST_ORDER_LINE = CUST_ORDER_LINE)
 
	IF @ABC_SERIAL_NUM IS NOT NULL
 
		BEGIN
		
		UPDATE SHIPPER_LINE SET LONG_DESCRIPTION = @ABC_SERIAL_NUM WHERE PACKLIST_ID = @PACKLIST_ID and LINE_NO = @PACKLIST_LINE
 
		END

Open in new window

0
Comment
Question by:D4430
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24033610
I presume the problem is because of the variable in the code defined as VARCHAR(50) ?

apart from that, change the code like this:
CREATE   TRIGGER ABC_UPDATE_PACK_LIST_SN ON [dbo].[SHIPPER_LINE] 
FOR INSERT 
AS 
  UPDATE sl 
     SET LONG_DESCRIPTION = sn.SERIAL_NUMBERS
    FROM INSERTED i
    JOIN ABCDE.dbo.ABC_SERIAL_NUMBERS sn
      ON sn.CUST_ORDER = i.CUST_ORDER_ID
     AND sn.CUST_ORDER_LINE = i.CUST_ORDER_LINE_NO
    JOIN SHIPPER_LINE sl 
      ON sl.PACKLIST_ID = i.PACKLIST_ID
     AND sl.LINE_NO = i.LINE_NO
   WHERE sn.SERIAL_NUMBERS IS NOT NULL
      
      

Open in new window

0
 

Author Comment

by:D4430
ID: 24033670
Thanks. When I increased the field to VARCHAR(8000) I could see the rest of the text.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL server 2012 BPA and Baseline Configuration Analyzer 2.0 16 30
SSIS GUID Variable 2 33
Convert VBA UDF to SQl SERVER UDF 4 49
T-SQL and CLR parameter strings 9 23
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question