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

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


Ïà¹ØÎĵµ£º

MsSql³£ÓÃÈÕÆÚ¸ñʽ

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 ......

MSSQL Óë EXCEL»¥²Ù×÷

SQL SERVER ºÍEXCELµÄÊý¾Ýµ¼Èëµ¼³ö
1¡¢ÔÚSQL SERVERÀï²éѯExcelÊý¾Ý:
-- ======================================================
SELECT *
from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
ÏÂÃæÊǸö²éѯµÄʾÀ ......

MSSQLÈ«ÎļìË÷

MSSQLÈ«ÎļìË÷ --1.´ò¿ªÊý¾Ý¿â
use pubs
go
--2.´ò¿ªÈ«ÎÄË÷ÒýÖ§³Ö
--execute sp_fulltext_database 'enable'
/*
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
£¨ËùÓ°ÏìµÄÐÐÊýΪ 0 ÐУ©
£¨ËùÓ°ÏìµÄÐÐÊýΪ 1 ÐУ©
*/ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ