November 11, 2013 at 9:35 pm
Hi There,
i have a query as below:
by running the sql i.e. select NAMEEMPL from SAMINC.dbo.ARSAP INNER JOIN dbo.Users ON NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS
it returns
NAMEEMPL
Bill Bhasion
Peter louder
I now want to use below to create my stored procedure for checking the values and returning it to the screen.
DECLARE @MyVar nvarchar(max);
SELECT @MyVar = NAMEEMPL from SAMINC.dbo.ARSAP INNER JOIN dbo.Users ON NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS
If (@MyVar = '')
Print 'No user name match, please create valid users matching from Sage ERP 300 to Sage CRM'
Else
Print 'User Matched from Sage ERP 300 to Sage CRM:' + CHAR(13) + @MyVar
GO
this query runs fine but it returns only one row of name i.e.
User Matched from Sage ERP 300 to Sage CRM:
Peter Louder
the actual result should be:
User Matched from Sage ERP 300 to Sage CRM:
Bill Bhasion
Peter Louder
i am not sure what i am doing wrong - please advise.
regards
November 11, 2013 at 9:55 pm
I fixed the issue by below query
DECLARE @MyVar nvarchar(max);
SELECT @MyVar = COALESCE(@MyVar + CHAR(13),'') + NAMEEMPL from SAMINC.dbo.ARSAP INNER JOIN dbo.Users ON NAMEEMPL = User_FirstName + ' ' + User_LastName Collate Latin1_General_CI_AS
If (@MyVar = '')
Print 'No user name match, please create valid users matching from Sage ERP 300 to Sage CRM'
Else
Print 'User Matched from Sage ERP 300 to Sage CRM:' + CHAR(13) + @MyVar
GO
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply