I have a sproc like so, it basically appends a prefix to a field if it does not already exist:
ALTER PROCEDURE [dbo].[AgSp_UpdateAgTbl_Licensing ](@newPrefix nvarchar, @systemName nvarchar)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
update AgTbl_Licensing
set UrlPrefixes =
case
when UrlPrefixes is null or UrlPrefixes = ''
then @newPrefix
else convert ( nvarchar( max ), UrlPrefixes) + ', '+@newPrefix
end
where SystemName = @systemName and (UrlPrefixes not like ('%'+@newPrefix+'%') or UrlPrefixes is null)
END
I try and call this like so:
Execute AgSp_UpdateAgTbl_Licensing 'eb_', 'EB1';
but updates are not being made to the db – how come? i cant debug as i dont have sysadmin
I think you should declare procedure parameters with length as;
Otherwise it will take only
FIRST characterof your string and therefore yourWHERE clause failsto find the records to be updated. And also your parameters are not what you expecting them to be.