SQL ³£Óô洢¹ý³Ì
³£Óô洢¹ý³Ì¼¯½õ,¶¼ÊÇһЩmssql³£ÓõÄһЩ£¬´ó¼Ò¿ÉÒÔ¸ù¾ÝÐèҪѡÔñʹÓá£
¡¡¡¡=================·ÖÒ³==========================
¡¡¡¡/*·ÖÒ³²éÕÒÊý¾Ý*/
¡¡¡¡CREATE PROCEDURE [dbo].[GetRecordSet]
¡¡¡¡@strSql varchar(8000),--²éѯsql,Èçselect * from [user]
¡¡¡¡@PageIndex int,--²éѯµ±Ò³ºÅ
¡¡¡¡@PageSize int--ÿҳÏÔʾ¼Ç¼
¡¡¡¡AS
¡¡¡¡set nocount on
¡¡¡¡declare @p1 int
¡¡¡¡declare @currentPage int
¡¡¡¡set @currentPage = 0
¡¡¡¡declare @RowCount int
¡¡¡¡set @RowCount = 0
¡¡¡¡declare @PageCount int
¡¡¡¡set @PageCount = 0
¡¡¡¡exec sp_cursoropen @p1 output,@strSql,@scrollopt=1,@ccopt=1,@rowcount=@rowCount output --µÃµ½×ܼǼÊý
¡¡¡¡select @PageCount=ceiling(1.0*@rowCount/@pagesize) --µÃµ½×ÜÒ³Êý
¡¡¡¡,@currentPage=(@PageIndex-1)*@PageSize+1
¡¡¡¡select @RowCount,@PageCount
¡¡¡¡exec sp_cursorfetch @p1,16,@currentPage,@PageSize
¡¡¡¡exec sp_cursorclose @p1
¡¡¡¡set nocount off
¡¡¡¡GO
¡¡¡¡=========================Óû§×¢²á============================
¡¡¡¡/*
¡¡¡¡Óû§×¢²á£¬Ò²ËãÊÇÌí¼Ó°É
¡¡¡¡*/
¡¡¡¡Create proc [dbo].[UserAdd]
¡¡¡¡(
¡¡¡¡@loginID nvarchar(50), ¡¡¡¡¡¡¡¡--µÇ¼ÕʺÅ
¡¡¡¡@password nvarchar(50), --ÃÜÂë
¡¡¡¡@email nvarchar(200) --µç×ÓÐÅÏä
¡¡¡¡)
¡¡¡¡as
¡¡¡¡declare @userID int --Óû§±àºÅ
¡¡¡¡--µÇ¼Õ˺ÅÒѾ±»×¢²á
¡¡¡¡if exists(select loginID from tableName where loginID = @loginID)
¡¡¡¡begin
¡¡¡¡return -1;
¡¡¡¡end
¡¡¡¡--ÓÊÏäÒѾ±»×¢²á
¡¡¡¡else if exists(select email from tableName where email = @email)
¡¡¡¡begin
¡¡¡¡return -2;
¡¡¡¡end
¡¡¡¡--×¢²á³É¹¦
¡¡¡¡else
¡¡¡¡begin
¡¡¡¡select @userID = isnull(max(userID),100000)+1 from tableName
¡¡¡¡insert into tableName
¡¡¡¡(userID,loginID,[password],userName,linkNum,address,email,createTime,status)
¡¡¡¡values
¡¡¡¡(@userID,@loginID,@password,'','','',@email,getdate(),1)
¡¡¡¡return @userID
¡¡¡¡end
==========================sql serverϵͳ´æ´¢¹ý³Ì===================
¡¡¡¡–1.¸ø±íÖÐ×Ö¶ÎÌí¼ÓÃèÊöÐÅÏ¢
¡¡¡¡Create table T2 (id int , name char (20))
¡¡¡¡
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÔÚDataContextÖÐÎÒÃÇ´ò½»µÀ×î¶àµÄÒ²Ðí¾ÍÊÇGetTable<TEntity>()·½·¨ÁË£¬Õâ¸ö·½·¨»á»ñȡһ¸öTable<TEntity>¶ÔÏ󣬽ñÌìÎÒÃǾÍÀ´¿´¿´Õâ¸ö¶ÔÏóÊÇÈçºÎ»ñÈ¡µÄ¡£
¡¡¡¡¶ÔÓÚ»ñÈ¡Table<TEntity>¶ÔÏóÎÒÃÇ»¹Òª¿´¿´Õâ¸öDataContextÊDz»ÊÇÇ¿ÀàÐ͵쬹ØÓÚÇ¿ÀàÐ͵ÄDataContext¿ÉÒÔ¿´ÎÒÇ°ÃæÒ»ÆªÎÄÕ£¬Ç¿ÀàÐ͵ÄDataContextÀ ......
1.²éѯ³öµ±Ç°Á¬½ÓÈ»ºó½«Æä¹Ø±Õ
select spid
from master.dbo.sysprocesses
where dbid= db_id('Êý¾Ý¿âÃû')
--db_id('DoNet')
Èçspid ֵΪ 52.
2. 執ÐÐ:
kill 52
3.ÐÞ¸Ä數據庫Ãû
EXEC sp_dboption 'old_db_name', 'Single User', 'false'
&nb ......
--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">
<Chapt ......
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
Õâ¶ÔÓÚÔÚÒª²»Í¬Êý¾Ý¿â¼ä×ªÒÆÊý¾Ý»òÕßϰ¹ßoracleÈÕÆÚ¸ñʽYYYY-MM-DD HH24:MI:SSµÄÈ˶àÉÙÓÐЩ²»·½±ã.
ÎÒÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄܾ³£»áÓõ½µÄÈÕÆÚ¸ñʽת»»·½·¨:
¾ÙÀýÈçÏÂ:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replac ......