Results 1 to 4 of 4

Thread: substringing declared varables in SQL Server

  1. #1
    Tom Arrowood Guest

    substringing declared varables in SQL Server

    I need to be able to update a row of data in a table based upon the first character of a char(50) field.

    if char(1) of employee_Job_class = "X" then update field Class_description = "Temporary"

    Anyone have any suggestions ??


  2. #2
    Gregory Guest

    substringing declared varables in SQL Server (reply)

    like this?:
    update <table>
    set Class_description = &#39;Temp&#39;
    where substring(employee_Job_class ,1,1) = &#39;X&#39;
    ...?

    ------------
    Tom Arrowood at 5/20/99 8:45:43 AM

    I need to be able to update a row of data in a table based upon the first character of a char(50) field.

    if char(1) of employee_Job_class = &#34;X&#34; then update field Class_description = &#34;Temporary&#34;

    Anyone have any suggestions ??


  3. #3
    Jarlath O'Grady Guest

    substringing declared varables in SQL Server (reply)

    UPDATE TABLENAME
    SET Class_description = CASE CONVERT(CHAR(1), employee_Job_class)
    WHEN &#34;X&#34; THEN &#34;Temporary&#34;
    ELSE Class_description

    This will update all records, &#34;X&#34; records will be have Class_description changed to &#34;Temporary&#34;, the rest will have
    Class_description updated to Class_description.

    Jarlath

    ------------
    Tom Arrowood at 5/20/99 8:45:43 AM

    I need to be able to update a row of data in a table based upon the first character of a char(50) field.

    if char(1) of employee_Job_class = &#34;X&#34; then update field Class_description = &#34;Temporary&#34;

    Anyone have any suggestions ??


  4. #4
    Guest

    substringing declared varables in SQL Server (reply)


    set Firstrst = db.openrecordset(&#34;select employee_job_class, Class_description from tbl?????(s)&#34
    with firstrst
    .movefirst
    do while .eof = false
    FirstChar = left(!employee_job_class, 1)
    if firstchar = &#34;X&#34; then
    !Class_description = = &#34;Temporary&#34;
    end if
    .movenext
    loop
    end with
    end sub

    something like that should work.... or else link to access and run an update query on the table....

    good luck
    kim
    ------------
    Tom Arrowood at 5/20/99 8:45:43 AM

    I need to be able to update a row of data in a table based upon the first character of a char(50) field.

    if char(1) of employee_Job_class = &#34;X&#34; then update field Class_description = &#34;Temporary&#34;

    Anyone have any suggestions ??


Posting Permissions

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