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
 General SQL Server Forums
 New to SQL Server Programming
 error processing a function return value

Author  Topic 

kiddoOnSQL
Starting Member

16 Posts

Posted - 2011-06-15 : 21:53:48
I have a list of employee names that I retrieve from a single column of a table which I then pass on to a Split function. The employee names from the source table are in the format 'Surname space Firstname'

The Split function returns both these values in separate variables that I then manipulate to re-format the emp id column of the source table. However I get 'The multi-part identifier "dbo.SMR_Employee_Lookup.nvFirstname" could not be bound.' error message

I am not sure how I can alias any of the tables or the Split function here to get rid of the error. Part of my SQL script is below:


if @ClientType='SMR'
Begin
declare @varfname varchar(100)
declare @varlname varchar(100)

Set @varfname = (Select top 1 (data) from dbo.Split(dbo.SMR_Employee_Lookup.nvFirstname, ' ') order by ID desc)

Set @varlname = (Select top 1 (data) from dbo.Split(dbo.SMR_Employee_Lookup.nvFirstname, ' ') )



Update dbo.SMR_Employee_Lookup
Set nvPersonID = ltrim(rtrim(nvPersonID)) + Substring(@varfname,1,1) + @varlname

End

Any suggestions??

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-06-16 : 01:25:32
you can use fnParseString() from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


Update dbo.SMR_Employee_Lookup
Set nvPersonID = ltrim(rtrim(nvPersonID))
+ Substring(dbo.fnParseString(-1, ' ', nvFirstname), 1, 1)
+ dbo.fnParseString(-2, ' ', nvFirstname)



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

Go to Top of Page
   

- Advertisement -