how do I can pass a string variable in an sql query to be excuted using EXEC sp_executesql?
the original and working query is:
update database01.dbo.Docs SET property1 = NULL where [name] like 'doc.xls'
I need to build this query to look like:
DECLARE @FileName NVARCHAR(30),
@Query NVARCHAR(MAX)
SET @fileName = 'doc.xls'
SET @Query = 'update database01.dbo.Docs SET property1 = NULL where [LeafName] like ' + @FileName
EXEC sp_executesql @Query
Many thanks for support.
Regards
Aucun commentaire:
Enregistrer un commentaire