SQL Server Forums
Profile | Register | 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
 New Topic  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
52325 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
52325 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
52325 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  
 New 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.08 seconds. Powered By: Snitz Forums 2000