问题描述如下:
Declare @Content varchar
Select top 1 Content From db.Table where Content like '%**%'
[email protected],应该如何操作呢?
------解决方案--------------------
Declare @Content varchar
select @Content=content from
(Select top 1 Content From db.Table where Content like '%**%')
------解决方案--------------------
Declare @Content varchar
select @Content=(Select top 1 Content From db.Table where Content like '%**%')
select @Content
------解决方案--------------------
- SQL code
Declare @Content varchar(1000)set @Content=(Select top 1 Content From db.Table where Content like '%**%')--orSelect top 1 @Content=Content From db.Table where Content like '%**%'
------解决方案--------------------
- SQL code
----set赋值不就可以了Declare @Content varcharset @Content=(Select top 1 Content From db.Table where Content like '%**%')
------解决方案--------------------
select
set
建议用set
------解决方案--------------------
直接set @Content=(Select top 1 Content From db.Table where Content like '%**%')
------解决方案--------------------
这里用set 和select 赋值都可以
------解决方案--------------------
Declare @Content varchar(1000)
set @Content=(Select top 1 Content From db.Table where Content like '%**%')
或者
Select top 1 @Content=Content From db.Table where Content like '%**%'
------解决方案--------------------
楼上都回答完了。
------解决方案--------------------
直接用set或select都可以
------解决方案--------------------
--方法一
DECLARE @Name VARCHAR(50);
SELECT TOP 1 @Name=Name FROM dbo.DataDictional
PRINT @Name
--方法二
SELECT @Name=(SELECT TOP 1 Name FROM dbo.DataDictional)
PRINT @Name
--方法三
SELECT @Name=Name FROM (SELECT TOP 1 Name FROM dbo.DataDictional) AS t
PRINT @Name