mssql ÁÐÄÚÊý¾ÝºáÏòÁ¬½Ó,ÓöººÅ·Ö¸î¡£
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[temp_Table]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[temp_Table]
GO
CREATE TABLE [dbo].[temp_Table] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[productname] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
insert into temp_table select column from table
declare @i int,@c int,@string varchar(5000),@j varchar(5000)
DECLARE @SQLString NVARCHAR(5000)
select @SQLString=N'select @c = count(*) from temp_table'
execute sp_executesql @sqlstring,
N'@c int output',
@c=@c output
set @i=1
set @string=''
while @i<=@c
begin
select @SQLString=N'select @j = productname from temp_table where id = '+cast(@i as varchar(5))
execute sp_executesql @sqlstring,
N'@j varchar(5000) output',
@j=@j output
select @string =@string + @j + ','
select @i=@i+1
end
select substring(@string,0,len(@string)-1)
drop table temp_table
Ïà¹ØÎĵµ£º
--> Title : varbinaryת»»³É×Ö·û´®
--> Author : wufeng4552
--> Date : 2009-12-15
declare @s varchar(20),@bin varbinary(1000)
select @s='www.CSDN.net',@bin=cast(@s as varbinary(1000))
declare @re varchar(1000),@i int
select @re='',@i=datalength(@bin)
while @i>0
&n ......
ÔÚµçÄÔÉÏ×°Á˸öÐéÄâ»ú£¬±¾»ú×°Á˸öMSSQL2000,ÔÚÐéÄâ»úÒ²×°Á˸öMSSQL2000£¬µ«Êǵ±Á¬½ÓÐéÄâ»úÉϵÄMSSQL£¬SQLÌáʾ³ö´í£¬ÎÞ·¨Á¬½Ó£¬¾õµÃºÜÆæ¹Ö£¬ÒòΪIPµØÖ·ÊDz»Í¬µÄ£¬×îºóÏëµ½Á˸ö°ì·¨£¬ÒòΪÊÇһ̨µçÄÔ£¬ËùÒԶ˿Ú1433Ö»ÓÐÒ»¸ö£¬±¾»úÕ¼ÁË1433£¬ÄÇôÐéÄâ»ú¾Íû·¨ÓÃÁË£¬Ïëµ½¾Í×ö£¬°ÑÐéÄâ»úµÄ¶Ë¿Ú¸Ä³ÉÁË1500¡£ÖØÆôµçÄÔ£¬µ«ÊÇ»¹ÊDz»Ä ......
SQL ServerÖÐÎÄ°æµÄĬÈϵÄÈÕÆÚ×Ö¶Îdatetime¸ñʽÊÇyyyy-mm-dd Thh:mm:ss.mmm
ÀýÈç:
select getdate()
2004-09-12 11:06:08.177
ÕûÀíÁËÒ»ÏÂSQL ServerÀïÃæ¿ÉÄܾ³£»áÓõ½µÄÈÕÆÚ¸ñʽת»»·½·¨:
¾ÙÀýÈçÏÂ:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVER ......
Ò»¡¢ÈÏʶË÷Òý
¡¡¡¡(Ò»)ÉîÈëdz³öÀí½âË÷Òý½á¹¹
¡¡¡¡Êµ¼ÊÉÏ£¬Äú¿ÉÒÔ°ÑË÷ÒýÀí½âΪһÖÖÌØÊâµÄĿ¼¡£Î¢ÈíµÄSQL SERVERÌṩÁËÁ½ÖÖË÷Òý£º¾Û¼¯Ë÷Òý(clustered index£¬Ò²³Æ¾ÛÀàË÷Òý¡¢´Ø¼¯Ë÷Òý)ºÍ·Ç¾Û¼¯Ë÷Òý(nonclustered index£¬Ò²³Æ·Ç¾ÛÀàË÷Òý¡¢·Ç´Ø¼¯Ë÷Òý)¡£ÏÂÃ棬ÎÒÃǾÙÀýÀ´ËµÃ÷һϾۼ¯Ë÷ÒýºÍ·Ç¾Û¼¯Ë÷ÒýµÄÇø±ð£º
¡¡¡¡Æäʵ£¬ÎÒà ......
create function dbo.regexReplace
(
@source varchar(5000), --Ô×Ö·û´®
@regexp varchar(1000), - ......