SQL XML
--Creating xml Data Type Columns
CREATE TABLE dbo.Book
(BookID int IDENTITY(1,1) PRIMARY KEY,
ISBNNBR char(10) NOT NULL,
BookNM varchar(250) NOT NULL,
AuthorID int NOT NULL,
ChapterDESC XML NULL)
DECLARE @Book XML
SET @Book =
CAST('<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1"> Installation, Upgrades... </Chapter>
<Chapter id="2"> Configuring SQL Server </Chapter>
<Chapter id="3"> Creating and Configuring Databases </Chapter>
<Chapter id="4"> SQL Server Agent and SQL Logs </Chapter>
</Chapters>
</Book>' as XML)
CREATE PROCEDURE dbo.usp_INS_Book
@ISBNNBR char(10),
@BookNM varchar(250),
@AuthorID int,
@ChapterDESC xml
AS
INSERT dbo.Book
(ISBNNBR, BookNM, AuthorID, ChapterDESC)
VALUES (@ISBNNBR, @BookNM, @AuthorID, @ChapterDESC)
GO
--Inserting xml Data into a Column
INSERT dbo.Book
(ISBNNBR, BookNM, AuthorID, ChapterDESC)
VALUES ('570X000000',
'SQL Server 2005 T-SQL Recipes',
55,
CAST('<Book name="SQL Server 2005 T-SQL Recipes">
<Chapters>
<Chapter id="1"> SELECT </Chapter>
<Chapter id="2"> INSERT,UPDATE,DELETE </Chapter>
<Chapter id="3"> Transactions, Locking, Blocking, and Deadlocking </Chapter>
<Chapter id="4"> Tables </Chapter>
<Chapter id="5"> Indexes </Chapter>
<Chapter id="6"> Full-text search </Chapter>
</Chapters>
</Book>' as XML))
DECLARE @Book XML
SET @Book =
CAST('<Book name="SQL Server 2000 Fast Answers">
<Chapters>
<Chapter id="1"> Installation, Upgrades... </Chapter>
<Chapter id="2"> Configuring SQL Server </Chapter>
<Chapter id="3"> Creating and Configuring Databases </Chapter>
<Chapter id="4"> SQL Server Agent and SQL Logs </Chapter>
</Chapters>
</Book>' as XML)
INSERT dbo.Book
(ISBNNBR, BookNM, AuthorID, ChapterDESC)
VALUES ('1590591615',
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
平时很少用SQL Server 2008,偶尔用一次,还真是遇到了一些问题,几经周折,从官网上才找到解决办法:
问题描述:登陆后,点击数据库,出现服务器主体 "xxxcom" 无法在当前安全上下文下访问数据库 "db_xxx_com"。
问题原因:SQL Server 2008 bug
问题解决办法(非原创,参考官网):
1、用SQL Server Management Studi ......
sql三表联合查询
a表:迟到记录表---------------------------------------------------------------------------------------------------------------------
姓名 职工编号 &nb ......
SQL Server中调用方法时,经常遇到.或是::两种调用方法,其中. 是实例调用方法,::是静态调用方法。如果大家对C#语法熟悉的话,. 对应C#中调用实例方法,:: 对应C#中的static方法。
下面给出一个SQL Server的实例,下面的SQL运行在2008环境下:
DECLARE @g geography;
SET @g = geography::Parse('LINESTRING(-122.360 ......
今天工作時候輸入數據庫中有一條數據字段記錄是"客戶否决"
使用
select * from TelephoneStatusCategory where CategoryName like '%客戶否%'
select * from TelephoneStatusCategory where CategoryName like '%客戶否决% ......