Time of Update: 2015-12-28
標籤: 通過作業的方式調用SQL執行自動備份,可以解決忘記備份資料庫的問題,記錄一下declare @FileFullName varchar(40);declare @FileName varchar(20);declare @ExecSql varchar(100);--declare @Filesuffix varchar(10);--@Filesuffix = ‘.bak‘;--set @FileName =
Time of Update: 2015-12-25
標籤:1.定義變數時可以直接賦值DECLARE @Id int = 5 2.Insert 語句可以一次插入多行資料INSERT INTO StateList VALUES(@Id, ‘WA‘), (@Id + 1, ‘FL‘), (@Id + 2, ‘NY‘) 3.支援+=操作符SET StateId += 1 SQL Server
Time of Update: 2015-12-25
標籤:在SQL
Time of Update: 2015-12-13
標籤:copy http://www.cnblogs.com/benwu/p/3939044.html主要描述的是SQL Server使用convert取得datetime日期資料的實際操作流程,在實際操作中用SQL Server資料庫中用convert來擷取datetime日期資料,以下執行個體包含各種日期格式的轉換。 語句及查詢結果: Select CONVERT(varchar(100), GETDATE(), 0):
Time of Update: 2015-12-11
標籤:類型轉換函式cast和convert--cast一般更容易使用,convert的優點是可以格式化日期和數值select CAST(‘123‘ as int) -- 123select CONVERT(int, ‘123‘) -- 123select CAST(123.4 as int) -- 123select CONVERT(int, 123.4) -- 123 select CAST(‘123.4‘ as int) --失敗select CONVERT(int, ‘123.
Time of Update: 2015-12-09
標籤:封裝好的Regex供SQLSERVER調用開啟資料庫->可程式化性->函數->純量值函式->建立純量值函式名USE [資料庫]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER function [dbo].[純量值函式名](@source ntext, --原字串@regexp varchar(1000), --Regex@replace varchar(1000), --替換值@globalReplace
Time of Update: 2015-12-03
標籤:1.在資料庫中建立兩張測試表建立使用者表use eftestgoif exists(select * from sysobjects where name=‘UserInfo‘)drop table UserInfocreate table UserInfo( ID int identity(1,1) primary key, UserName nvarchar(100) not null, Sex char(1) default ‘男‘, age int
Time of Update: 2015-12-05
標籤: 1. 死結原理 根據作業系統中的定義:死結是指在一組進程中的各個進程均佔有不會釋放的資源,但因互相申請被其他進程所站用不會釋放的資源而處於的一種永久等待狀態。 死結的四個必要條件:互斥條件(Mutual exclusion):資源不能被共用,只能由一個進程使用。請求與保持條件(Hold and wait):已經得到資源的進程可以再次申請新的資源。非剝奪條件(No
Time of Update: 2015-12-02
標籤:伺服器突然中了病毒,查殺後,結果兩個服務也丟了, 從其他機器上COPY了兩個EXE過來,編寫這兩個服務就搞定了,不用重裝MSSQL2005了 sc create MSSQLSERVER binpath= "\"C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe\" -sMSSQLSERVER" displayname= "SQL Server (MSSQLSERVER)" depend=
Time of Update: 2015-12-04
標籤:SQL Server 中截取字串常用的函數:1.LEFT ( character_expression , integer_expression )函數說明:LEFT ( ‘源字串‘ , ‘要截取最左邊的字元數‘ )返回從字串左邊開始指定個數的字元select LEFT(‘SQL_Server_2008‘,4 );返回結果:SQL_2.RIGHT ( character_expression , integer_expression )函數說明:RIGHT ( ‘源字串‘ ,
Time of Update: 2015-12-03
標籤:CREATE FUNCTION [dbo].[Getxxxxxxxxx] ( @productCategoryId INT, @SplitChar varchar )RETURNS NVARCHAR(MAX)AS BEGIN DECLARE @returnProductCategory NVARCHAR(MAX)=N‘‘/*-- 注意,CTE
Time of Update: 2015-12-01
標籤:if object_ID(‘[proc_SelectForPager]‘) is not null Drop Procedure [proc_SelectForPager]GoCreate Proc proc_SelectForPager( @Tb_name varchar(max) ,--表名 @Order varchar(4000) ,--排序欄位 @CurrentPage int ,--當前頁 @Field varchar(400),--查詢欄位 @PageSize
Time of Update: 2015-11-27
標籤:每次從伺服器上備份好資料庫(Sql Server資料庫),如果將備份資料庫檔案在本地恢複,總會產生使用者權限的問題。經過很多次的實驗後,我發現有那麼一條語句可以發揮作用,就是sp_change_users_login語句。具體用法:EXEC sp_change_users_login ‘Update_One‘, ‘使用者名稱‘,
Time of Update: 2015-11-29
標籤:--3.建立有空間資料的表create table x( v int not null identity(1,1) primary key, geog geography not null, geogWKT as geog.STAsText())--4.增加空間資料insert into x(geog)values(geography::Parse(‘POLYGON( (-93.123 36.943,
Time of Update: 2015-11-25
標籤:CREATE PROCEDURE sp_DeleteAllDataASEXEC sp_MSForEachTable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL‘--禁用約束EXEC sp_MSForEachTable ‘ALTER TABLE ? DISABLE TRIGGER ALL‘--禁用觸發器EXEC sp_MSForEachTable ‘DELETE FROM ?‘--清資料EXEC sp_MSForEachTable ‘ALTER
Time of Update: 2015-11-26
標籤:在建立資料庫的時候,報整個錯誤 Cannot read property is filestream 此屬性不可用於sql server 7.0 按照網上的方法 (http://blog.csdn.net/tryfinally/article/details/7207048),在sql組態管理員中,開啟filestream 選項,並且執行 EXEC sp_configure filestream_access_level,
Time of Update: 2015-11-21
標籤:SQL Server錯誤記錄檔(AG)SQL Server錯誤記錄檔會記錄影響AG的時間,比如:1.和Windows容錯移轉叢集互動2.可用副本的狀態3.可用資料的狀態4.AG endpoint的狀態5.AG Listener的狀態6.SQL Server resource DLL和SQL
Time of Update: 2015-11-17
標籤:轉載:http://www.2cto.com/database/201306/216922.html 資料庫,角色,使用者,安全 登入SQL server 2008可以用windows身分識別驗證也可以用sql
Time of Update: 2015-11-14
標籤:SQL Server表 表的類型: ①暫存資料表暫存資料表可用來處理中間資料或者用暫存資料表與其它串連共用進行中的工作。暫存資料表只能放在tempdb中。私人暫存資料表(#)全域暫存資料表(##) ②系統資料表用來儲存所有資料庫物件、資料類型、約束、配置選項等相關資訊的表。 屬性的資料類型 1.基礎資料型別 (Elementary Data
Time of Update: 2015-11-10
標籤:觸發器是一種特殊類型的預存程序。觸發器和預存程序的區別:觸發器主要是通過事件進行觸發被自動調用執行的,而預存程序可以通過預存程序的名稱被調用。 什麼是觸發器