Sql Server添加单引号

时间:2021-05-10 00:42:20
" ' "(单引号)的运用:在sql server中,两个" ' "(单引号)在拼接字符串的情况下运用,就是表示拼接上了一个" ' "单引号字符串。

SELECT TOP 1 ''''+CONVERT(nvarchar(50),keyid)+'''' name1 FROM Rel_ProductStockLock with (nolock) WHERE KeyId IS NOT NULL
SELECT TOP 1 ''''+CONVERT(nvarchar(50),keyid)+''',' name2 FROM Rel_ProductStockLock with (nolock) WHERE KeyId IS NOT NULL
SELECT '''' name3;
SELECT '123''' name4;
SELECT '123'+'' name5;
SELECT  '"123"' name6;
SELECT TOP 1 '123'+AreaName name7 FROM dbo.Dim_Area;
SELECT TOP 1 '123'''+AreaName name8 FROM dbo.Dim_Area;
SELECT TOP 1 '123'''+AreaName+''  name9 FROM dbo.Dim_Area;
SELECT TOP 1 '123'''+AreaName+'''' name10 FROM dbo.Dim_Area;
 

Sql Server添加单引号

 

 

--查询线上被锁定LPN
SELECT TOP 3 ''''+CONVERT(nvarchar(50),d.LpnId)+'''', d.LpnId,r.sourcebarcode,* FROM dbo.Rel_ProductStockLock r (NOLOCK)
inner JOIN dbo.Fct_ProductStockDetail d(NOLOCK) ON r.KeyId=d.ProductStockDetailId
WHERE r.LockType=6 AND r.Status=0 AND d.Stock>0 and r.Disabled=0 and d.Disabled=0

--'90350753'

 

https://www.cnblogs.com/zhaosw/p/6088040.html  关于sql 拼接字符串的问题