Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SqlServerÊý¾Ý¿âµÄÓï¾ä¼°Ò»Ð©²Ù×÷ÕûÀí

ÁÙ½üÄêÖÕ£¬ÔÚ¹¤×÷Ö®Óà¶Ô¹¤×÷ºÍѧϰÖÐÓöµ½µÄÎÊÌâÒÔ¼°³£ÓõÄһЩ֪ʶµã×öÁËЩÕûÀí£¬ÒÔ±¸ºóÓᣱ¾ÎÄÉæ¼°µÄÄÚÈÝΪÊý¾Ý¿â,ËãÊǶԿª·¢×ܽá(1)---Êý¾Ý¿âÒ»ÎĵIJ¹³ä¡£
1 ¶ÔÓÚÖ÷¼üÉèÖÃÁËIdentityµÄ±í£¬ÔÚɾ³ý±íÖÐÊý¾ÝºóÔÙÍù±íÖвåÈëÊý¾Ý£¬IdentityÁв»ÊÇ´Ó1ÆðʼÁË£¬Èç¹ûÏëɾ³ýÊý¾ÝºóIndentityÁÐÈÔ´Ó1Æðʼ£¬¿ÉÒÔÓÃÏÂÃæ´úÂëÀ´É¾³ýÊý¾Ý¡£
truncate table tablename
DBCC CHECKIDENT(tablename,RESEED,1)
2 ÅжÏÖ¸¶¨±íÔÚÊý¾Ý¿âÖÐÊÇ·ñ´æÔÚ
if exists(select name from sysobjects where name='tablename' and type='u')
3 ÅжÏÖ¸¶¨ÁÐÔÚÖ¸¶¨±íÖÐÊÇ·ñ´æÔÚ
if exists(select * from sys.columns,sys.tables
where sys.columns.object_id = sys.tables.object_id
and sys.tables.name='tablename' and sys.columns.[name]='columnname')
4 ÔÚ±àд´úÂëÉú³ÉÆ÷Ö®ÀàµÄ³ÌÐòµÄʱºò£¬Í¨³£ÐèҪȡ³öÊý¾Ý¿âÖÐËùÓеıíÃûÒÔ¼°±íÖÐ×ֶεÄһЩ»ù±¾ÐÅÏ¢£¬Èç×ֶγ¤¶È¡¢×Ö¶ÎÀàÐÍ¡¢ÃèÊöµÈ¡£ÊµÏÖÉÏÃæÒªÇóµÄsqlÓï¾äÈçÏ£º
--È¡Êý¾Ý¿âÖбíµÄ¼¯ºÏ
select * from sysobjects where xtype='u' order by name
--È¡±íÖÐ×ֶεÄһЩ»ù±¾ÐÅÏ¢
select
sys.columns.name, --×Ö¶ÎÃû
sys.types.name as typename, --×Ö¶ÎÀàÐÍ
sys.columns.max_length, --×ֶ㤶È
sys.columns.is_nullable, --ÊÇ·ñ¿É¿Õ
(select
count(*)
from
sys.identity_columns
where
sys.identity_columns.object_id = sys.columns.object_id
and
sys.columns.column_id = sys.identity_columns.column_id
) as is_identity ,--ÊÇ·ñ×ÔÔö
(select
value
from
sys.extended_properties
where
sys.extended_properties.major_id = sys.columns.object_id
and
sys.extended_properties.minor_id = sys.columns.column_id
) as description --×¢ÊÍ
from
sys.columns, sys.tables, sys.types
where
sys.columns.object_id = sys.tables.object_id
and
sys.columns.system_type_id=sys.types.system_type_id
and
sys.tables.name='tablename'
order by sys.columns.column_id
5 ÔÚ´æ´¢¹ý³ÌÖÐʹÓÃÊÂÎñ
create procedure procname
as
begin tran
--Ö´ÐÐsqlÓï¾ä
if @@ERROR!=0
begin


Ïà¹ØÎĵµ£º

SQLServerÖеÄÑ­»·Åú´¦Àí

if (object_id ('t' ) is not null ) drop table t
go
create table t (id int identity (1 , 1 ), name varchar (40 ))
go
insert into t (name ) select newid ()
go 10
select * from t
/*
1    18C1C418-9029-4599-8D5E-616354A113C8
2    A0FE1177-09D8-4C56-9FB5-C2FA ......

¡¾¸Äб¹éÕý¡¿ sqlserver sql ·ÖÒ³Óï¾ä

      ÔÚGoogleÉÏʹÓÓsql ·ÖÒ³”¹Ø¼ü×Ö½øÐÐËÑË÷£¬¼¸ºõËùÓеĴ𰸶¼ÊÇÄÇÈýÌõ¡£Æä¶þЧÂÊ×î¸ß£¬ÆäÈýʹÓÃÓα꣬ЧÂÊ×î²î¡£
      ÏÂÃæÊÇÄÇÈýÖÖ·½·¨ £¨²åÈë´úÂëûÓÐsqlÑ¡Ï
·½·¨1£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE ......

Ëø³õ̽(sqlserver 2005)

HOLDLOCK ½«¹²ÏíËø±£Áôµ½ÊÂÎñÍê³É£¬¶ø²»ÊÇÔÚÏàÓ¦µÄ±í¡¢ÐлòÊý¾ÝÒ³²»ÔÙÐèҪʱ¾ÍÁ¢¼´ÊÍ·ÅËø¡£HOLDLOCK µÈͬÓÚ SERIALIZABLE¡£
NOLOCK ²»Òª·¢³ö¹²ÏíËø£¬²¢ÇÒ²»ÒªÌṩÅÅËüËø¡£µ±´ËÑ¡ÏîÉúЧʱ£¬¿ÉÄÜ»á¶ÁȡδÌá½»µÄÊÂÎñ»òÒ»×éÔÚ¶ÁÈ¡ÖÐ¼ä»Ø¹öµÄÒ³Ãæ¡£ÓпÉÄÜ·¢ÉúÔà¶Á¡£½öÓ¦ÓÃÓÚ SELECT Óï¾ä¡£
 PAGLOCK ÔÚͨ³£Ê¹Óõ¥¸ö±íËøµ ......

c#ÖиßЧµÄexcelµ¼ÈësqlserverµÄ·½·¨

±¾ÎÄÀ´×ÔCSDN²©¿Í£ºhttp://blog.csdn.net/jinjazz/archive/2008/07/14/2650506.aspx
½«oledb¶ÁÈ¡µÄexcelÊý¾Ý¿ìËÙ²åÈëµÄsqlserverÖУ¬ºÜ¶àÈËͨ¹ýÑ­»·À´Æ´½Ósql£¬ÕâÑù×ö²»µ«ÈÝÒ׳ö´í¶øÇÒЧÂʵÍÏ£¬×îºÃµÄ°ì·¨ÊÇʹÓÃbcp£¬Ò²¾ÍÊÇSystem.Data.SqlClient.SqlBulkCopy ÀàÀ´ÊµÏÖ¡£²»µ«Ëٶȿ죬¶øÇÒ´úÂë¼òµ¥£¬ÏÂÃæ²âÊÔ´úÂëµ¼ÈëÒ»¸ö6 ......

SQLSERVER×ÔÔöÖ÷¼ü

SQLServer Öк¬×ÔÔöÖ÷¼üµÄ±í£¬Í¨³£²»ÄÜÖ±½ÓÖ¸¶¨IDÖµ²åÈ룬¿ÉÒÔ²ÉÓÃÒÔÏ·½·¨²åÈë¡£
1. SQLServer ×ÔÔöÖ÷¼ü´´½¨Óï·¨£º
identity(seed, increment)
ÆäÖÐ
seed Æðʼֵ
increment ÔöÁ¿
ʾÀý£º
create table student(
      id int identity(1,1),
      name varcha ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ