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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 stored procedure for update query

Author  Topic 

ppatel112
Starting Member

35 Posts

Posted - 2013-10-23 : 00:28:11
Hi All,

I have written a update query but I need to compile it in a stored procedure, I tried various attempts but was unsuccessfull.

here is my update query.
UPDATE c
SET c.comp_primaryuserid = u.user_userid
FROM dbo.Company AS c INNER JOIN
SAMINC.dbo.ARCUS AS y ON y.IDCUST = c.Comp_IdCust Collate Latin1_General_CI_AS INNER JOIN
SAMINC.dbo.ARSAP AS z ON z.CODESLSP = y.CODESLSP1 INNER JOIN
dbo.Users AS u ON z.NAMEEMPL = u.User_FirstName + ' ' + u.User_LastName Collate Latin1_General_CI_AS

any help would be appreciated.

regards,
parth

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-10-23 : 00:29:50
what is the error message ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ppatel112
Starting Member

35 Posts

Posted - 2013-10-23 : 00:42:40
thanks for the response - I haven't been able to write the correct stored procedure as I haven't written any before
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-23 : 02:03:48
procedure will look like thus

CREATE PROC Updatedata
AS
UPDATE c
SET c.comp_primaryuserid = u.user_userid
FROM dbo.Company AS c INNER JOIN
SAMINC.dbo.ARCUS AS y ON y.IDCUST = c.Comp_IdCust Collate Latin1_General_CI_AS INNER JOIN
SAMINC.dbo.ARSAP AS z ON z.CODESLSP = y.CODESLSP1 INNER JOIN
dbo.Users AS u ON z.NAMEEMPL = u.User_FirstName + ' ' + u.User_LastName Collate Latin1_General_CI_AS
GO


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -