Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 set with select statement
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

seekerPoet
Starting Member

4 Posts

Posted - 09/27/2012 :  11:06:09  Show Profile  Reply with Quote
I am wanting to update a temp table in a sp by the following script:

UPDATE #SalesDetail
SET DriverName = SELECT DriverName FROM EP_Main.vDriver v INNER JOIN #SalesDetail sd
on v.DriverID = sd.DriverID

It errors out at the select

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  11:10:33  Show Profile  Reply with Quote
syntax was wrong

it should be


UPDATE sd
SET sd.DriverName = v.DriverName 
FROM EP_Main.vDriver v 
INNER JOIN #SalesDetail sd 
on v.DriverID = sd.DriverID


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

seekerPoet
Starting Member

4 Posts

Posted - 09/27/2012 :  11:30:28  Show Profile  Reply with Quote
Thank you for such quick response. When I run code against this sp it now errors out saying it can not find EP_Main.vDriver. This is a view so how do you gain data from a view using the script above.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  11:34:27  Show Profile  Reply with Quote
is EP_Main your schema name? if not only this is enough

UPDATE sd
SET sd.DriverName = v.DriverName 
FROM Driver v 
INNER JOIN #SalesDetail sd 
on v.DriverID = sd.DriverID


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

seekerPoet
Starting Member

4 Posts

Posted - 09/27/2012 :  11:37:01  Show Profile  Reply with Quote
EP_Main is one dbase entity of several
Go to Top of Page

seekerPoet
Starting Member

4 Posts

Posted - 09/27/2012 :  11:48:24  Show Profile  Reply with Quote
solved it. it needed to be EP_Main.dbo.vdriver
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 09/27/2012 :  11:57:22  Show Profile  Reply with Quote
ok...then that means EP_Main is your database name

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000