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

½«±íÊý¾ÝÉú³ÉSQL½Å±¾µÄ´æ´¢¹ý³Ì

CREATE PROCEDURE dbo.UspOutputData
@tablename sysname
AS
declare @column varchar(1000)
declare @columndata varchar(1000)
declare @sql varchar(4000)
declare @xtype tinyint
declare @name sysname
declare @objectId int
declare @objectname sysname
declare @ident int
set nocount on
set @objectId=object_id(@tablename)
if @objectId is null -- Åж϶ÔÏóÊÇ·ñ´æÔÚ
begin
print 'The object not exists'
return
end
set @objectname=rtrim(object_name(@objectId))
if @objectname is null or charindex(@objectname,@tablename)=0 --´ËÅжϲ»ÑÏÃÜ
begin
print 'object not in current database'
return
end
if OBJECTPROPERTY(@objectId,'IsTable') < > 1 -- Åж϶ÔÏóÊÇ·ñÊÇtable
begin
print 'The object is not table'
return
end
select @ident=status&0x80 from syscolumns where id=@objectid and status&0x80=0x80
if @ident is not null
print 'SET IDENTITY_INSERT '+@TableName+' ON'
declare syscolumns_cursor cursor
for select c.name,c.xtype from syscolumns c where c.id=@objectid order by c.colid
open syscolumns_cursor
set @column=''
set @columndata=''
fetch next from syscolumns_cursor into @name,@xtype
while @@fetch_status < >-1
begin
if @@fetch_status < >-2
begin
if @xtype not in(189,34,35,99,98) --timestamp²»Ðè´¦Àí£¬image,text,ntext,sql_variant ÔÝʱ²»´¦Àí
begin
set @column=@column+case when len(@column)=0 then'' else ','end+@name
set @columndata=@columndata+case when len(@columndata)=0 then '' else ','','','
end
+case when @xtype in(167,175) then '''''''''+'+@name+'+''''''''' --varchar,char
when @xtype in(231,239) then '''N''''''+'+@name+'+''''''''' --nvarchar,nchar
when @xtype=61 then '''''''''+convert(char(23),'+@name+',121)+''''''''' --datetime
when @xtype=58 then '''''''''+convert(char(16),'+@name+',120)+''''''''' --smalldatetime
when @xtype=36 then '''''''''+convert(char(36),'+@name+')+''''''''' --uniqueidentifier
else @name end
end
end
fetch next from syscolumns_cursor int


Ïà¹ØÎĵµ£º

MS SQLÈëÃÅ»ù´¡:Ë÷ÒýÊÓͼ

 MS SQLÈëÃÅ»ù´¡:Ë÷ÒýÊÓͼ
ÊÕ²Ø



¡¡
¡¡ÔÚÇ°ÃæÎÒÃÇÒѾ­Ìáµ½¹ýÓйØÊÓͼµÄÏÂÊö¹Ûµã£ºÓÉÓÚÊÓͼ·µ»ØµÄ½á¹û¼¯Óë¾ßÓÐÐÐÁнṹµÄ±íÓÐ×ÅÏàͬµÄ±í¸ñÐÎʽ£¬²¢ÇÒÎÒÃÇ¿ÉÒÔÔÚSQL
Óï¾äÖÐÏñÒýÓñíÄÇÑùÒýÓÃÊÓͼ£¬ËùÒÔÎÒÃdz£°ÑÊÓͼ³ÆΪÐé±í¡£±ê×¼ÊÓͼµÄ½á¹û¼¯²¢²»ÒÔ ......

SQL ServerÖÐʹÓÃCLRµ÷ÓÃ.NET·½·¨

½éÉÜ
ÎÒÃÇÒ»ÆðÀ´×ö¸öʾÀý£¬ÔÚ.NETÖÐн¨Ò»¸öÀ࣬²¢ÔÚÕâ¸öÀàÀïн¨Ò»¸ö·½·¨£¬È»ºóÔÚSQL ServerÖе÷ÓÃÕâ¸ö·½·¨¡£°´ÕÕ΢ÈíËùÊö£¬Í¨¹ýËÞÖ÷ Microsoft .NET Framework 2.0 ¹«¹²ÓïÑÔÔËÐпâ (CLR)£¬SQL Server 2005ÏÔÖøµØÔöÇ¿ÁËÊý¾Ý¿â±à³ÌÄ£ÐÍ¡£ ÕâʹµÃ¿ª·¢ÈËÔ±¿ÉÒÔÓÃÈκÎCLRÓïÑÔ£¨ÈçC#¡¢VB.NET»òC++µÈ£©À´Ð´´æ´¢¹ý³Ì¡¢´¥·¢Æ÷ºÍÓ ......

SQL Server 2005 18452,18470µÇ¼´íÎóµÄ½â¾ö·½·¨

±¾ÎĵØÖ·£ºhttp://qzone.qq.com/blog/236000056-1217427602
ÎÞ·¨Á¬½Óµ½·þÎñÆ÷  
·þÎñÆ÷£ºÏûÏ¢18452, ¼¶±ð16£¬×´Ì¬1  
[Microsoft][ODBC  SQLServer Driver][SQL Server]Óû§‘sa’µÇ½ʧ°Ü¡£Ô­Òò£ºÎ´ÓëÐÅÈÎSQL     ServerÁ¬½ÓÏà¹ØÁª  
¸Ã´íÎó²úÉ ......

SQLÓï¾äÓÅ»¯¼¼Êõ·ÖÎö

×î½ü¼¸ÖÜÒ»Ö±ÔÚ½øÐÐÊý¾Ý¿âÅàѵ£¬ÀÏʦ¾«Õ¿µÄ¼¼ÊõºÍÉú¶¯µÄ½²½âʹÎÒÊÜÒæ·Ëdz¡£ÎªÁËÈøü¶àµÄÐÂÊÖÊÜÒ棬ÎÒ³é¿Õ°ÑSQLÓï¾äÓÅ»¯²¿·Ö½øÐÐÁËÕûÀí£¬Ï£Íû´ó¼ÒÒ»Æð½ø²½¡£¡¡¡¡
¡¡¡¡Ò»¡¢²Ù×÷·ûÓÅ»¯¡¡¡¡
¡¡1¡¢IN ²Ù×÷·û ¡¡¡¡
¡¡¡¡ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊÇ±È½Ï ......

ÔÚSQL ServerÖÐʹÓÃNewID()·½·¨²úÉúËæ»ú¼¯

ÔÚSQL ServerÖÐʹÓÃNewID()·½·¨²úÉúËæ»ú¼¯
ÀýÈ翼ÊÔϵͳÖеÄËæ»ú³öÌâ
¸Õ¿ªÊ¼Ïëµ½µÄÊÇRandomÀà
µ«ÊÇRandomЧÂÊÓеãµÍ
ºóÀ´Ïëµ½ÁËÔÚÊý¾Ý¿âÀïµÄnewid()
ÓÚÊDzÉÓÃÁËϱ߷½·¨£º
select top 5 * from tablename order by newid()
Ôڴ˱ê¼ÇһϠ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ