Microsoft SQL Server
なにかと便利になってきたデータベース。
サーバ
クライアント

■エディションと機能

最大メモリ最大利用可能コアデータベースサイズManagement
Studio
全文検索Reporting
Services
Reporting Services
(SharePoint連携)
Express1GB1cpu/4coreまで10GB××××
Express with Tools1GB1cpu/4coreまで10GB×××
Express with
Advanced Services
1GB1cpu/4coreまで10GB×
Standard64GB4cpu/16coreまでほぼ無制限

■phpでバイナリ―データを扱う
データ登録
$i=1;
$f="imagefile.png";
$dsn = "sqlsrv:server=localhost\express;database=ChEMBL_13";
$dbh=new PDO($dsn,'foo','bar');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $dbh->prepare("INSERT into IMAGETBL(ID, snapshot) values ( ?, ?)");
$fp = fopen($f,'rb');
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->bindParam(2, $fp, PDO::PARAM_LOB,0,PDO::SQLSRV_ENCODING_BINARY );
$dbh->beginTransaction();
$sth->execute();
$dbh->commit();

データ参照
$dsn = "sqlsrv:server=localhost\express;database=ChEMBL_13";
$dbh=new PDO($dsn,'foo','bar');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth=$dbh->prepare("SELECT snapshot FROM IMAGETBL where ID=1");
$sth->execute();
$sth->bindColumn(1,$image,PDO::PARAM_LOB,0, PDO::SQLSRV_ENCODING_BINARY);
$sth->fetch(PDO::FETCH_BOUND);
file_put_contents("imagefile.png",$image);

メモ

小ネタ
■連番を振る
UPDATE table_a
SET table_a.ID=tmp.idx
FROM (
SELECT table_a.ID,table_a.MOL, ROW_NUMBER() OVER (ORDER BY table_a.ID,table_a.MOL) AS idx
FROM table_a
) AS tmp
WHERE
table_a.ID=tmp.ID AND table_a.MOL=tmp.MOL

■縦に複数のデータを横並びで取得したい
https://webbibouroku.com/Blog/Article/forxmlpath

最新の60件
2026-05-09 2026-05-08 2026-05-06 2026-05-05 2026-05-04 2026-05-03 2026-05-02 2026-04-30 2026-04-29 2026-04-28 2026-04-27 2026-04-25 2026-04-24 2026-04-22 2026-04-21 2026-04-12 2026-04-08 2026-04-06 2026-04-05 2026-04-02 2026-03-26 2026-03-23 2026-03-21 2026-03-19 2026-03-15 2026-03-14 2026-03-13 2026-03-07 2026-03-06 2026-03-04 2026-03-02 2026-02-26 2026-02-24 2026-02-21 2026-02-18 2026-02-17 2026-02-16 2026-02-11 2026-02-09

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-03-29 (金) 01:10:48