Quantcast
Channel: SQL Server Setup & Upgrade forum
Viewing all articles
Browse latest Browse all 7696

Stored Procedure Can't Find Particular Record

$
0
0

I have the following stored procedure in our data warehouse db (SQL Server 2012):

ALTER PROCEDURE [dbo].[GetAccessRight]

	@ServiceUser nvarchar(50),
	@Column nvarchar(8)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

DECLARE 	@SQL as nvarchar(100)

SET @SQL = 'SELECT ' + @Column + ' FROM [tblACL] WHERE [User] = ''' + @ServiceUser + ''''

EXECUTE sp_executesql @SQL

END


GO

tblACL is a list of email addresses and services. Against each address there are '1's in the columns associated with the services they are allowed to access. The stored procedure allows Outlook to determine whether or not the person requesting information is authorised to receive a response.

It all works fine except for one particular person who's name is in tblACL but the stored procedure just can't see it. Case in point; the following returns nothing...

exec GetAccessRight @ServiceUser='harriet=companyname.co.uk@companyname.email', @Column='ACL4'
 

...but this correctly returns 1...

SELECT [ACL4]
FROM [Datashed].[dbo].[tblACL]
WHERE [User] = 'harriet=companyname.co.uk@companyname.email'

The astute amongst you will notice that that's a very weird email address. It is, but I don't think that's the issue because the system works fine for all Harriet's equally weird colleagues.

Anyone got any idea as to what's going on and how to fix it?

Nick.


Viewing all articles
Browse latest Browse all 7696

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>