How To Change SQL Server 2008/2005 Object Schema?
Problem
It is not easy to change SQL Server 2008/2005 object schema (tables, stored procedures and views) to “dbo”. Here is a solution.
It is not easy to change SQL Server 2008/2005 object schema (tables, stored procedures and views) to “dbo”. Here is a solution.
How to format datetime & date in Sql Server 2005
June 11, 2009 — Anubhav Goyal
Execute the following Microsoft SQL Server T-SQL datetime and date formatting scripts in Management Studio Query Editor to demonstrate the multitude of temporal data …
One of the most frequently asked questions in SQL Server forums is how to format a datetime value or column into a specific date format. Here’s a summary of the different date formats that come standard in SQL Server as …
SET IDENTITY_INSERT [Table] ON|OFF
注意一次只能有一个Table能在On的状态!要及时关闭!…
sqlserver删除数据库中所有的表
如果由于外键约束删除table失败,则先删除所有约束:
–/第1步**********删除所有表的外键约束*************************/
DECLARE c1 cursor for
select ‘alter table [‘+ object_name(parent_obj) + ‘] drop constraint [‘+name+’]; ‘
from sysobjects
where xtype = ‘F’
open c1
declare @c1 varchar(8000)
fetch next from c1 into @c1
while(@@fetch_status=0)
begin
exec(@c1)
fetch next …
Inside Microsoft SQL Server 2005: T-SQL Programming:
Transactions allow you to define a unit of activity that will be considered atomic—all or nothing. The data will be considered consistent at the beginning of the transaction and at the end. …
SQL の CASE 式って知ってますか? :: Drk7jp:
今日、同僚から MySQL って CASE 式を SQL の中に記述できましたっけ?と聞かれて、SQL 文に CASE – when 式を記述できることを初めて知りました。PL/SQL でのみ有効な構文かと勘違いしてました。
CASE 式はSQL-92 で標準に取り入れられており、意外と歴史は古いです。SQL99 からかと思いました。しかしながら、超便利な CASE 式を知っている人は意外と少ないと思います。Oracle なら同様の処理が記述できる DECODE 関数の方がメジャーですね。実際僕もこちらを用いて業務 SQL を書いてました。
が、CASE 式の方が明らかに高機能でした。DECODE 関数を使っているOracleユーザには、是非CASE 式への乗り換えを勧めます。CASE 式には下記の通り4つの利用方法があります。…
CASE式は SQL-92 で標準に取り入れられた、割と新しい道具です。そのため、便利な割に真価があまり知られておらず、利用されていなかったり、CASE式の簡略版である DECODE や COALESCE などの関数で代用されていたりします。しかしセルコが「SQL-92 で追加された中で最も有用かもしれない」[1]と言うように、CASE式を活用すると SQL でできることの幅がぐっと広がり、書き方もスマートになります。特に、DECODE関数を使っている Oracle ユーザには、是非 CASE式への乗り換えを勧めます[2]。
以下では、CASE式の魅力の一端を解説します。例によって『プログラマのためのSQL 第2版』から多くを受け売っています。
稼働環境:Oracle(9i以降)、SQLServer、DB2、PostgreSQL、MySQL
まず基本的な文法から解説しましょう。CASE式の書式には、単純CASE式(simple case)と検索CASE式(searched case)という二通りがあります。それぞれ、次のように書きます。
utl_file_dirのセット方法
①init.oraのUTL_FILE_DIR=’*’を追加する
②show parameters utl_file_dir
Oracle8.1.7でテスト済み…