update table statement

  • I am tring to update a column on one table from another.

    Using the code below it parses ok but get the error multi part identifier cannot be found

    update ct_user

    set dbo.nt_name=ct_users1$._nt_name where dbo.ct_user.name =dbo.ct_users1$._staffName

    any reason why i am getting this error.

    Thanks,

    Iain

  • looks like all you are missing is the FROM clause:

    update ct_user

    set dbo.nt_name = [ct_users1$]._nt_name

    FROM [ct_users1$]

    where dbo.ct_user.name = dbo.[ct_users1$]._staffName

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • From what you've given us it's difficult to help, can't correct your code can just point you in the right way. Looks like you're missing a FROM clause to me.

    UPDATE table_name

    SET column_name = expression

    FROM other_table_name

    WHERE search_conditions

    -EDIT- Lowell, you ninja. . . 😛


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • low hanging fruit, my friend; so easy i couldn't resist 😀

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for the advice guys managed to get it working with the following sql

    update ct_user

    set ct_user.nt_name =(select _nt_name from dbo.ct_users1$ where dbo.ct_user.name =dbo.ct_users1$._staffName)

    😛

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply