Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のようなクエリがあります。
select * from Table1 where name like '%ASD%'
この種のことができるように変更したい:
declare @name1 varchar(255) select @name1 = 'dfg' select * from Table1 where name like @name1
どうすればそれを達成できますか?
試す:
SELECT * FROM Table1 WHERE name LIKE '%' + @name1 + '%'
そしてSET @name1 = 'dfg'代わりにSELECT @name1 = 'dfg'
SET @name1 = 'dfg'
SELECT @name1 = 'dfg'
SETに値を割り当てるために使用し@name1、必ず目的の検索文字列に設定してください (通常、これはパーセント記号で始まり、1 つ、またはその両方で終わると見なされます)。
SET
@name1
set @name1 = '%dfg%'