插入查询中的内连接?

use*_*618 3 c# sql insert

我想做这样的事情:

insert into TableA 
   (val1,val2) 
values
   ("value",(select top 1 tableB.X from tableB where tableB.Y=@Y))
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

在此上下文中不允许子查询.只允许标量表达式

如何阻止该错误?

ris*_*onj 9

假设您正在使用SQL Server:

insert into tableA 
  (val1, val2) 
select top 1 'value', tableB.x from tableB where tableB.Y = @y 
Run Code Online (Sandbox Code Playgroud)