SQLÅжÏ×Ö¶ÎÀàÐÍ
-->Title:Generating test data
-->Author:wufeng4552
-->Date :2009-09-25 09:56:07
if object_id('tb')is not null drop table tb
go
create table tb(ID int,name text)
insert tb select 1,'test'
go
--·½·¨1
select sql_variant_property(ID,'BaseType') from tb
--·½·¨2
select object_name(ID)±íÃû,
c.name ×Ö¶ÎÃû,
t.name Êý¾ÝÀàÐÍ,
c.prec ³¤¶È
from syscolumns c
inner join systypes t
on c.xusertype=t.xusertype
where objectproperty(id,'IsUserTable')=1 and id=object_id('tb')
Ïà¹ØÎĵµ£º
Ò»¡¢¼òµ¥²éѯ
¡¡¡¡ ¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣
ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable WHERE name='ÕÅÈý'
(Ò»)Ñ¡ÔñÁбí
¡ ......
if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
declare
@i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  ......
ÕªÒª£º±¾ÎĽ«½éÉÜSQL Server 2005 Analysis ServicesÖÐÊý¾ÝÍÚ¾òËã·¨À©Õ¹·½·¨£¬ÔÚÆ½Ê±¿ª·¢ÖÐÎÒÃÇÐèÒª¸ù¾ÝÒªÇóÀ´À©Õ¹SSASµÄÍÚ¾òËã·¨¡£
±êÇ©£ºSQL Server 2005 Êý¾ÝÍÚ¾ò Ëã·¨
SSASΪÎÒÃÇÌṩÁ˾ÅÖÖÊý¾ÝÍÚ¾òËã·¨£¬µ«ÊÇÔÚÓ¦ÓÃÖÐÎÒÃÇÐèÒª¸ù¾Ýʵ¼ÊÎÊÌâÉè¼ÆÊʵ±µÄËã·¨£¬Õâ¸öʱºò¾ÍÐèÒªÀ©Õ¹SSA ......