Results 1 to 5 of 5

Thread: Modifying Data

  1. #1
    Join Date
    Apr 2004
    Posts
    73

    Unanswered: Modifying Data

    I am trying to modify data in a tble using the Stored Procedure below. It doesnt work properly. I seem to only be getting one character. I think it has something to do with me using "nchar" with the variables. The value I am changing is actually a string.

    Code:
    Alter Procedure usp_UpdateJobName
    
    @JobNameOld nchar, @JobNameNew nchar
    
    As
    
    UPDATE 
    	JobName
    	SET
    	JobName=@JobNameNew
    
    FROM
    	tblRMADATA
    
    WHERE
    	tblRMADATA.JobName=@JobNameOld

  2. #2
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    u need to declare the input as a string of characters
    like @jobnamenew nchar(n)
    @jobnameold nchar(n)
    n being the expected length of jobname.
    since u have declared it as nchar only one character will be selected.

  3. #3
    Join Date
    Apr 2004
    Posts
    73
    I changed that. I am getting an error now and it says invalied object name. It doesn't seem to like "JobName". JobName is a column in the tblRMAData table. Instead of nchar I am using nvarchar because that is the data field type in the table.

    Here is my new code.
    Code:
    Alter Procedure "usp_UpdateJobName"
    
    @JobNameOld nvarchar(50), @JobNameNew nvarchar(50)
    
    As
    
    UPDATE 
    	JobName
    	SET
    	JobName=@JobNameNew
    
    FROM
    	tblRMADATA
    
    WHERE
    	tblRMADATA.JobName=@JobNameOld

  4. #4
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34

    Talking Try this

    Alter Procedure "usp_UpdateJobName"

    @JobNameOld nvarchar(50), @JobNameNew nvarchar(50)

    As

    UPDATE
    tblRMADATA
    SET
    JobName=@JobNameNew



    WHERE
    tblRMADATA.JobName=@JobNameOld

  5. #5
    Join Date
    Apr 2004
    Posts
    73
    Thanks .... that worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •