国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

SQL 一些小技巧

2024-07-21 02:06:10
字體:
來源:轉載
供稿:網友


these has been picked up from thread within sqljunkies forums http://www.sqljunkies.com

problem
the problem is that i need to round differently (by halves)
example: 4.24 rounds to 4.00, but 4.26 rounds to 4.50.
4.74 rounds to 4.50 and 4.76 rounds to 5.00

solution
declare @t float
set @t = 100.74
select round(@t * 2.0, 0) / 2

problem
i'm writing a function that needs to take in a comma seperated list and us it in a where clause. the select would look something like this:

select * from people where firstname in ('larry','curly','moe')

solution
use northwind
go

declare @xvar varchar(50)
set @xvar = 'anne,janet,nancy,andrew, robert'

select * from employees where @xvar like '%' + firstname + '%'


problem
need a simple paging sql command

solution
use northwind
go

select * from products a
where (select count(*) from products b where a.productid >= b.productid) between 15 and 16


problem
perform case-sensitive comparision within sql statement without having to use the set command

solution

use norhtwind
go

select * from products as t1
where t1.productname collate sql_ebcdic280_cp1_cs_as = 'chai'

--execute this command to get different collate naming
--select * from ::fn_helpcollations()

 

problem
how to call a stored procedure located in a different server

solution

set nocount on
use master
go

exec sp_addlinkedserver '172.16.0.22',n'sql server'
go

exec sp_link_publication @publisher = '172.16.0.22',
@publisher_db = 'northwind',
@publication = 'northwind', @security_mode = 2 ,
@login = 'sa' , @password = 'sa'
go

exec [172.16.0.22].northwind.dbo.custorderhist 'alfki'
go

exec sp_dropserver '172.16.0.22', 'droplogins'
go

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长丰县| 安吉县| 三河市| 南乐县| 扶绥县| 循化| 都安| 洛川县| 交口县| 彩票| 连江县| 清苑县| 永嘉县| 平度市| 长阳| 甘德县| 罗山县| 福海县| 道孚县| 临武县| 五台县| 都匀市| 晋宁县| 新乐市| 中西区| 聊城市| 婺源县| 岗巴县| 麦盖提县| 胶州市| 高阳县| 南投市| 阳东县| 建德市| 拉萨市| 游戏| 沾化县| 雷波县| 白银市| 承德县| 淮阳县|