顯示具有 SqlServer 標籤的文章。 顯示所有文章
顯示具有 SqlServer 標籤的文章。 顯示所有文章

2018年6月5日 星期二

[SQL]找出P Key不連續編號


select beginId,
(select min(id)-1 from table where id > beginId) as endId
from ( 
select id+1 as beginId from table
where id+1 not in
(select id from table)
and id < (select max(id) from table) 
) as t

參考資料: https://hk.saowen.com/a/3af383a9bedac1adf87c3dd66fc912d13d90555368f1ea66077c42e802f14880

2017年7月24日 星期一

[SQL Server]維護計劃失敗解決方式

在執行維護計畫時出現已下錯誤訊息,
可能是因為同事將主機名稱改過,
目前是先將擁有者改為sa即可。


2015年2月25日 星期三

[SQL Server]stored procedure 發送Email

dbmail設定完成後可在stored procedure 下以下發送mail sql
exec msdb.dbo.sp_send_dbmail
@profile_name='test',   --設定檔名稱
@recipients='00@gmail.com', --收件者
@subject='test',  --主旨
@body='test001', --內文
@query='你的條件式',  --查詢條件
--@file_attachments='',  --夾帶檔
@attach_query_result_as_file=0,  -- 值為0:將@query顯示在信件內文 值為1將附加在附件內
@body_format=TEXT    --設定text格式or html格式

2014年5月7日 星期三

使用者登入失敗(管道的另一端上無任何處理程序)

已在SqlServer上建立登入使用者,但是登入時會出現使用者登入失敗(管道的另一端上無任何處理程序)等訊息。

解決方式:

      再組態管理員將SQLEXPRESS的通訊協動  Shared Memory/具名管道/TCP IP狀態設為啟用就
      可以登入。


Visual Studio JS intellisense 失效解決方式

  試了好久,發現到工具>選項>IntelliCode js項目設定啟用,重新開啟VS就正常了! 後來發現是TypeScript3.2版有問題停用,使用4.3版的TypeScript即可