一.計算列的寫法
create table [dbo].[test](
[birthday] [varchar](8) collate chinese_prc_ci_as not null constraint [df_tbl_account_birthday] default (convert([char](8),getdate(),(112))),
[year] as (datediff(year,[birthday],getdate())),
)二.如果儲存過程中,包含儲存過程,且外層儲存過程在事務中。
內層儲存過程保錯,外層是否會提示錯誤。 答案是會。
如下儲存,如果test2正常,test1錯誤。2個儲存都不會生效
但是如果沒有加事務,test2就會生效
alter procedure test3
asbegin
set nocount on;
begin tran
exec test2
exec test1
if @@error<>0
begin
rollback tran
endelse
begin
commit tran
endend
三,動態語句執行和呼叫動態語句的儲存過程不是同一sission id
如果在動態語句中對臨時表插入資料,在呼叫的儲存過程中是看不到的。
這時需要使用全域性臨時表
if object_id('tempdb.dbo.##onlinedata_temp') is null
用來判斷全域性臨時表是否已經存在
四,阻塞和死鎖
可以參考下面部落格寫得非常好
下面語句可以檢視阻塞
select blocking_session_id, wait_duration_ms, session_id from sys.dm_os_waiting_tasks
透過以下兩個命令,我們還能看到整個資料庫的鎖定和阻塞詳細資訊:
select * from sys.dm_tran_locks
exec sp_lock
if object_id('tempdb.dbo.##onlinedata_temp') is null
一些小細節
1 c中printf計算引數時是從右到左壓棧的。定義乙個陣列 int arr 再定義乙個指標 sint prt arr printf d n ptr 此時ptr指向第乙個元素6 ptr 123展開為 ptr ptr 123 ptr 此時ptr指向第二個元素7 printf d,d n ptr,ptr...
response一些小細節
1 response 向客戶機輸出資料。2 位元組流 outputstream 可以輸出任何的資料,而字元流 writer 只能寫字元資料 3 respone.setheader content type text html charset utf 8 控制瀏覽器,指定編碼是utf 8 上面語句等同...
C 一些小細節
一 class 類 與 inlcude 類.h 的區別 class 類的使用,只是宣告有這麼乙個類,但是沒辦法呼叫類裡面的函式 而 include則可以 例如 pragma once include cocos2d.h include class scenemanger using ns cc cl...