如何在变量 SQL 服务器中创建查询语句大小写
How to make query statement case in variable SQL Server
这个有效:
select
idpelamar,
case
when jk = 'L' then 'Laki'
when jk = 'P' then 'Perem'
end as XJENIS
from tblpelamar
如何应用case
语句初始化一个变量?
像下面这样:
declare @jenis nvarchar(1)
declare @perintah nvarchar(100)
set @jenis = 'L'
set @perintah = 'case when jk=@jenis then Laki when jk=@jenis then Prem end as XJENIS'
select
idpelamar,
+@perintah
from tblpelamar
这是否回答了您的问题?
declare @jenis1 as nvarchar(1) = 'L';
declare @jenis2 as nvarchar(1) = 'P';
select idpelamar,
case jk
when @jenis1 then 'Laki'
when @jenis2 then 'Prem'
end as XJENIS
from tblpelamar;
这个有效:
select
idpelamar,
case
when jk = 'L' then 'Laki'
when jk = 'P' then 'Perem'
end as XJENIS
from tblpelamar
如何应用case
语句初始化一个变量?
像下面这样:
declare @jenis nvarchar(1)
declare @perintah nvarchar(100)
set @jenis = 'L'
set @perintah = 'case when jk=@jenis then Laki when jk=@jenis then Prem end as XJENIS'
select
idpelamar,
+@perintah
from tblpelamar
这是否回答了您的问题?
declare @jenis1 as nvarchar(1) = 'L';
declare @jenis2 as nvarchar(1) = 'P';
select idpelamar,
case jk
when @jenis1 then 'Laki'
when @jenis2 then 'Prem'
end as XJENIS
from tblpelamar;