I am having a problem getting this UPDATE statement to execute. No error is returned, it just does not update the table.
@recordExists varchar(10),
@fileName varchar(50),
@itemCode varchar (50),
--@uploadDate datetime,
@submittedBy varchar(30),
@revision varchar(50),
@itemCode5 varchar(50),
@itemCkDigit varchar(10),
@suffix varchar(10)
AS
DECLARE @sql varchar(1000)
DECLARE @uploadDate datetime
SET @uploadDate = GetDate()
-- Establish update or insert in to the graphics info table.
IF @recordExists = 'Y'
SET @sql = 'UPDATE tblGraphicInfo SET [uploadDate] = ''' + CONVERT(nvarchar(20), @uploadDate) + ''', [submittedBy] = ''' + @submittedBy + ''' WHERE [itemCode] = "' + @itemCode + '"; '
EXEC(@sql)
ELSE
Any help would be appreciated.
FYI, I changed passing the date in because I thought that was the problem. The uploadDate field is defined as a datetime field in the tblGraphicInfo table.
Your issue is your where statement
You will want to wrap strings in single quote (‘) not double quote (“). When escaping them in your string, you will need to double the single quotes.
You might also look at sp_executsql. It has a much cleaner syntax for handling parameters.