´æ´¢¹ý³ÌµÄ´´½¨¼°Ê¹ÓÃ(sqlserver 2005)
´æ´¢¹ý³ÌµÄ´´½¨¼°Ê¹ÓÃ(sqlserver 2005)
´´½¨´æ´¢¹ý³Ì¡£´æ´¢¹ý³ÌÊÇÒѱ£´æµÄ Transact-SQL Óï¾ä¼¯ºÏ£¬»ò¶Ô Microsoft .NET Framework ¹«¹²ÓïÑÔÔËÐÐʱ (CLR) ·½·¨µÄÒýÓ㬿ɽÓÊÕ²¢·µ»ØÓû§ÌṩµÄ²ÎÊý¡£¿ÉÒÔ´´½¨¹ý³Ì¹©ÓÀ¾ÃʹÓ㬻òÔÚÒ»¸ö»á»°£¨¾Ö²¿ÁÙʱ¹ý³Ì£©ÖÐÁÙʱʹÓ㬻òÔÚËùÓлỰ£¨È«¾ÖÁÙʱ¹ý³Ì£©ÖÐÁÙʱʹÓá£
Æô¶¯ SQL Server µÄÒ»¸öʵÀýʱ£¬Ò²¿ÉÒÔ´´½¨²¢×Ô¶¯ÔËÐд洢¹ý³Ì¡£
Transact-SQL Óï·¨Ô¼¶¨
Óï·¨
CREATE { PROC | PROCEDURE } [schema_name.] procedure_name [ ; number ]
[ { @parameter [ type_schema_name. ] data_type }
[ VARYING ] [ = default ] [ [ OUT [ PUT ]
] [ ,...n ]
[ WITH <procedure_option> [ ,...n ]
[ FOR REPLICATION ]
AS { <sql_statement> [;][ ...n ] | <method_specifier> }
[;]
<procedure_option> ::=
[ ENCRYPTION ]
[ RECOMPILE ]
[ EXECUTE_AS_Clause ]
<sql_statement> ::=
{ [ BEGIN ] statements [ END ] }
<method_specifier> ::=
EXTERNAL NAME assembly_name.class_name.method_name
±¸×¢
Transact-SQL ´æ´¢¹ý³ÌµÄ×î´ó´óСΪ 128 MB¡£
Ö»ÄÜÔÚµ±Ç°Êý¾Ý¿âÖд´½¨Óû§¶¨Òå´æ´¢¹ý³Ì¡£ÁÙʱ¹ý³Ì¶Ô´ËÊǸöÀýÍ⣬ÒòΪËüÃÇ×ÜÊÇÔÚ tempdb Öд´½¨¡£Èç¹ûδָ¶¨¼Ü¹¹Ãû³Æ£¬ÔòʹÓô´½¨¹ý³ÌµÄÓû§µÄĬÈϼܹ¹¡£Óйؼܹ¹µÄÏêϸÐÅÏ¢£¬Çë²ÎÔÄÓû§¼Ü¹¹·ÖÀë¡£
ÔÚµ¥¸öÅú´¦ÀíÖУ¬CREATE PROCEDURE Óï¾ä²»ÄÜÓëÆäËû Transact-SQL Óï¾ä×éºÏʹÓá£
ĬÈÏÇé¿öÏ£¬²ÎÊý¿ÉΪ¿ÕÖµ¡£Èç¹û´«µÝ NULL ²ÎÊýÖµ²¢ÇÒÔÚ CREATE »ò ALTER TABLE Óï¾äÖÐʹÓøòÎÊý£¬¶ø¸ÃÓï¾äÖб»ÒýÓÃÁÐÓÖ²»ÔÊÐíʹÓÿÕÖµ£¬ÔòÊý¾Ý¿âÒýÇæ »á²úÉúÒ»¸ö´íÎó¡£ÈôÒª×èÖ¹Ïò²»ÔÊÐíʹÓÿÕÖµµÄÁд«µÝ NULL£¬ÇëΪ¹ý³ÌÌí¼Ó±à³ÌÂß¼£¬»òʹÓà CREATE TABLE »ò ALTER TABLE µÄ DEFAULT ¹Ø¼ü×Ö£¬ÒÔ±ã¶Ô¸ÃÁÐʹÓÃĬÈÏÖµ¡£
´æ´¢¹ý³ÌÖеÄÈκΠCREATE TABLE »ò ALTER TABLE Óï¾ä¶¼½«×Ô¶¯´´½¨ÁÙʱ±í¡£½¨Òé¶ÔÓÚÁÙʱ±íÖеÄÿÁУ¬ÏÔʽָ¶¨ NULL »ò NOT NULL¡£Èç¹ûÔÚ CREATE TABLE »ò ALTER TABLE Óï¾äÖÐδ½øÐÐÖ¸¶¨£¬Ôò ANSI_DFLT_ON ºÍ ANSI_DFLT_OFF Ñ¡Ï¿ØÖÆÊý¾Ý¿âÒýÇæ ΪÁÐÖ¸ÅÉ NULL »ò NOT NULL ÊôÐԵķ½Ê½¡£Èç¹ûij¸öÁ¬½ÓÖ´ÐеĴ洢¹ý³Ì¶ÔÕâЩ
Ïà¹ØÎĵµ£º
ÔÚwindows 7 ÉÏΪ sqlserver 2008 ÆôÓÃÔ¶³Ì·ÃÎÊ£¬ÐèÒªÁ½¸öÖصãµÄ²½Öè¡£
µÚÒ»²½£ºÆôÓÃsqlserver 2008Ô¶³Ì·ÃÎʵŦÄÜ¡£
´ò¿ªMicrosoft SQL Server 2008-ÅäÖù¤¾ß-SQL Server ÅäÖùÜÀíÆ÷
ÆôÓò¢¼¤»îTcp/IP
È»ºóÖØÆôsqlserver·þÎñ¡£ÕâÑùsqlserver 2008¾Í¿ÉÒÔ½øÐÐÔ¶³ÌÁ¬½ÓÁË¡£µ«ÊÇwin7 ·À»ðǽĬÈÏÊÇ×èÖ¹ÁËsqlsever ¿ª· ......
Create Procedure up_InsertData2
@ID INT
AS
BEGIN
Declare @Name NVARCHAR(30)
Declare @c1 NVARCHAR(30)
Declare @c2 NVARCHAR(30)
Declare @c3 NVARCHAR(30)
Declare @c4 NVARCHAR(30)
Declare tmpCur Cursor For Select a,b,c,d from table1
Open tmpCur;
Fetch Next from tmpCur Into @c1,@c2,@c3 ......
if exists (select * from dbo.sysobjects where name='SplitStr' )
drop FUNCTION SplitStr
go
CREATE FUNCTION SplitStr (@splitString varchar(8000), @separate varchar(10))
RETURNS @returnTable ......