と併用してはいけません私はこのコードを実行すると、このエラーにA SELECT文は、データ検索operations1
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations
を得続ける:
SELECT
@i = Users,
(NAME + ' ' + Surname) AS names
FROM
dbo.HelpDeskUsers
WHERE
[names] LIKE @userid
を、私は別のを試してみました道...
SET
@i = (SELECT
[Users],
([Name] + ' ' + [Surname]) AS [names]
FROM
dbo.HelpDeskUsers
WHERE
Names LIKE @userid)
と私はこのエラーを取得する:
あなたはこのselect @i=Users
from dbo.HelpDeskUsers
where Name + ' ' + Surname = @userid
を探している間違っていないよ場合はこれがどのようにあなたが同じselect
クエリwhere
句でAlias
名前を使用することはできませんし、あなたがあなたのクエリ
で他の多くのミスを持っている210
Msg 207, Level 16, State 1, Procedure test, Line 17
Invalid column name 'Names'Msg 116, Level 16, State 1, Procedure test, Line 19
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
ここであなたの目標は何ですか? 'Select'クエリの結果を表示したい場合にも' Users'値を '@ i'に代入しますか? –
mysqlまたはsql-server? –
はい、私は、where句で名前として2列を連結する必要もあります。SQL-Server – monasensiva