General information
Forum:
Microsoft SQL Server
Title:
EXECUTE COMMAND PROBLEM
I wrote the following code and cannot get it to run:
DECLARE @RequestID UNIQUEIDENTIFIER,
@TempTableName VARCHAR(36),
@Cmd NVARCHAR(200)
SET @RequestID = NEWID()
SET @CMD = N'SELECT [TypeIDField], [DataValue] FROM RequestProperty_tbl re LEFT OUTER JOIN ' + @TempTableName + ' AS t ' + 'ON t.[ID] = re.[TypeIDField] WHERE re.[RequestID] = ' + @RequestID
EXECUTE SP_EXECUTESQL @CMD
--Server: Msg 403, Level 16, State 1, Line 7
--Invalid operator for data type. Operator equals add, type equals nvarchar.
How can I format it with the @RequestID UniqueIdentifier to run correctly?
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only