none
update t-able

    Question

  • CREATE TABLE [dbo].[EDI_COMMON_TABLE](
    	[EDI_GROUP] [char](50) NOT NULL,
    	[SEQ_NO] [smallint] NOT NULL,
    	[REFERENCE] [varchar](50) NOT NULL,
    	[DATE_FLD1] [date] NULL,
    	[DATE_FLD2] [date] NULL,
    	[CHAR_FLD1] [varchar](100) NULL,
    	[CHAR_FLD2] [varchar](100) NULL,
    	[CHAR_FLD3] [varchar](100) NULL,
    	[CHAR_FLD4] [varchar](100) NULL,
    	[CHAR_FLD5] [varchar](100) NULL,
    	[CHAR_FLD6] [varchar](100) NULL,
    	[CHAR_FLD7] [varchar](100) NULL,
    	[CHAR_FLD8] [varchar](100) NULL,
    	[CHAR_FLD9] [varchar](100) NULL,
    	[ACTIVE] [bit] NULL,
     CONSTRAINT [PK_EDI_COMMON_TABLE] PRIMARY KEY NONCLUSTERED 
    (
    	[EDI_GROUP] ASC,
    	[SEQ_NO] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    I have a table with the following create statement above AND I WAS ASK TO UPDATE THE TABLE TO INCLUDE 

    [CHAR_FLD1] with the values 1604 & 2103 how do I go about this from the create table I guess the sequence number is assigned automatically or am I to provide value for it.

    SELECT

    [EDI_GROUP]

         

    ,[SEQ_NO]

         

    ,[REFERENCE]

         

    ,[DATE_FLD1]

         

    ,[DATE_FLD2]

         

    ,[CHAR_FLD1]

         

    ,[CHAR_FLD2]

         

    ,[CHAR_FLD3]

         

    ,[CHAR_FLD4]

         

    ,[CHAR_FLD5]

         

    ,[CHAR_FLD6]

         

    ,[CHAR_FLD7]

         

    ,[CHAR_FLD8]

         

    ,[CHAR_FLD9]

         

    ,[ACTIVE]

     

    FROM [PHPCustom].[dbo].[EDI_COMMON_TABLE]

     

    WHERE  [EDI_GROUP] = 'PASO_CLAIMS_DRAG'


     

    and REFERENCE ='BCAT'


     

    and ACTIVE ='1'

    Thursday, August 14, 2014 5:22 PM

Answers

  • I have a table with the following create statement above AND I WAS ASK TO UPDATE THE TABLE TO INCLUDE [CHAR_FLD1] with the values 1604 & 2103 how do I go about this from the create table I guess the sequence number is assigned automatically or am I to provide value for it.

    How do you decide which row to be updated with 1604 or 2103? What is the logic?

    This how a typical update statement looks like:

    UPDATE [dbo].[EDI_COMMON_TABLE](
    SET [CHAR_FLD1] = 1604 --OR 2103
    WHERE [EDI_GROUP] = 'PASO_CLAIMS_DRAG'
    and REFERENCE ='BCAT'
    and ACTIVE ='1' --Your logic will decide what would be the condition


    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

    Thursday, August 14, 2014 6:05 PM

All replies

  • Please explain what you're trying to do. The current explanation is not clear:

    What rows will need to have [CHAR_FLD1] set to 1604 and what rows will have [CHAR_FLD1] set to 2103?

    Why are those columns set to VARCHAR(100) if the values to include are in fact integer?

    What do you need any kind of reference to a sequence number for? There's no logic in your explanation why the two values would have any relation to any kind of a sequence number....

    Thursday, August 14, 2014 5:56 PM
  • I have a table with the following create statement above AND I WAS ASK TO UPDATE THE TABLE TO INCLUDE [CHAR_FLD1] with the values 1604 & 2103 how do I go about this from the create table I guess the sequence number is assigned automatically or am I to provide value for it.

    How do you decide which row to be updated with 1604 or 2103? What is the logic?

    This how a typical update statement looks like:

    UPDATE [dbo].[EDI_COMMON_TABLE](
    SET [CHAR_FLD1] = 1604 --OR 2103
    WHERE [EDI_GROUP] = 'PASO_CLAIMS_DRAG'
    and REFERENCE ='BCAT'
    and ACTIVE ='1' --Your logic will decide what would be the condition


    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

    Thursday, August 14, 2014 6:05 PM