Need help with Syntax on Update or Insert SQL Statement 
Author Message
 Need help with Syntax on Update or Insert SQL Statement

I want to update the values in a column in table #1 with the values from
a column in table #2 where the servernames are equal.  What is the
proper syntax?  I've been trying this:

  UPDATE BCBSMServerInventroy
        SET  ServerInventroy.InstallDate = NT_compete.InstallDate
        WHERE ServerInventroy.ServerName = NT_compete.ServerName

and it doesn't work.  I get no errors.  I have also tried this:

SELECT ManuInstallDate INTO ServerInventroy
FROM  NT_complete
WHERE servername = servername

this does not give me the correct results either.  it just creates a new
table with 1 column containing the correct data.  I need this data put
into my original table.

Kimberly Killian

*** Sent via Developersdex http://www.***.com/ ***
Don't just participate in USENET...get rewarded for it!



Tue, 26 Oct 2004 22:27:18 GMT
 Need help with Syntax on Update or Insert SQL Statement

This is one method.  I am sure that others will post different solutions:

UPDATE table#1 SET InstallDate = B.InstallDate
FROM table#1 A JOIN table#2 B ON A.Servername = B.Servername
/*optional*/
WHERE A.InstallDate <> B.InstallDate

--
Posted on Microsoft news server at msnews.microsoft.com
If you are reading this from any other location, skip the middleman and come
to the source of the information!

Keith, SQL Server MVP


Quote:
> I want to update the values in a column in table #1 with the values from
> a column in table #2 where the servernames are equal.  What is the
> proper syntax?  I've been trying this:

>   UPDATE BCBSMServerInventroy
>         SET  ServerInventroy.InstallDate = NT_compete.InstallDate
>         WHERE ServerInventroy.ServerName = NT_compete.ServerName

> and it doesn't work.  I get no errors.  I have also tried this:

> SELECT ManuInstallDate INTO ServerInventroy
> FROM  NT_complete
> WHERE servername = servername

> this does not give me the correct results either.  it just creates a new
> table with 1 column containing the correct data.  I need this data put
> into my original table.

> Kimberly Killian

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Tue, 26 Oct 2004 22:36:00 GMT
 Need help with Syntax on Update or Insert SQL Statement
Add a FROM clause in your Update, By the way, which table are you
updating?  BCBSMServerInventroy or ServerInventroy?

UPDATE ServerInventroy
        SET  InstallDate = NT_compete.InstallDate
FROM NT_compete
        WHERE ServerInventroy.ServerName = NT_compete.ServerName

Thanks
Anith


Quote:
> I want to update the values in a column in table #1 with the values from
> a column in table #2 where the servernames are equal.  What is the
> proper syntax?  I've been trying this:

>   UPDATE BCBSMServerInventroy
>         SET  ServerInventroy.InstallDate = NT_compete.InstallDate
>         WHERE ServerInventroy.ServerName = NT_compete.ServerName

> and it doesn't work.  I get no errors.  I have also tried this:

> SELECT ManuInstallDate INTO ServerInventroy
> FROM  NT_complete
> WHERE servername = servername

> this does not give me the correct results either.  it just creates a new
> table with 1 column containing the correct data.  I need this data put
> into my original table.

> Kimberly Killian

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Tue, 26 Oct 2004 22:39:21 GMT
 Need help with Syntax on Update or Insert SQL Statement

Quote:
>   UPDATE BCBSMServerInventroy
>         SET  ServerInventroy.InstallDate = NT_compete.InstallDate
>         WHERE ServerInventroy.ServerName = NT_compete.ServerName

> and it doesn't work.  I get no errors.  I have also tried this:

Your UPDATE table and the table in your WHERE clause do not match.  Did you
mean:

   UPDATE ServerInventroy
         SET  InstallDate = NT_compete.InstallDate
         WHERE ServerInventroy.ServerName = NT_compete.ServerName

or

   UPDATE BCBSMServerInventroy
         SET  InstallDate = NT_compete.InstallDate
         WHERE BCBSMServerInventroy.ServerName = NT_compete.ServerName

?

www.aspfaq.com



Tue, 26 Oct 2004 22:37:54 GMT
 Need help with Syntax on Update or Insert SQL Statement
And of course add the FROM clause as others have mentioned.


Tue, 26 Oct 2004 22:43:54 GMT
 Need help with Syntax on Update or Insert SQL Statement

IT WORKED!!!!

Thank you so much!

Kimberly Killian

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Tue, 26 Oct 2004 22:51:04 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. SQL Update Statement Syntax Help

2. Help with SQL update statement syntax

3. Need help with a simple SQL statement (syntax)

4. Need Syntax Help With SQL Update Query

5. Update statement syntax -- Please Help!!

6. Help needed with SQL - Update Statement

7. Need Help - SQL update statement

8. need help w/ syntax for stored procedure w/ case statement

9. need help with syntax for CONTAINS statement

10. PL/SQL Update/Insert, Need Help

11. Need help with Select statement syntax to retrieve Access2000 record between two dates

12. need help with syntax for CONTAINS statement


 
Powered by phpBB® Forum Software