SQL¼ÓÃÜÊý¾Ý
ÍõÑà½Ü
ÔÚÍøÂçÉÏ·¢ËÍÊý¾Ý¶¼»á·¢ÉúһЩÑÏÖصݲȫÎÊÌ⣬ÍøÂç×î´óµÄµ£ÓÇÔÚÓÚÓÐÈË¿ÉÒÔ²¶»ñÊý¾Ý£¬sqlserverÖ§³Ö²ÉÓÃÖ¤ÊéÀ´¼ÓÃÜ
1£®´´½¨Ö¤Êé
create master key encryption by
password = 'administrator123'
--ÓÃÃÜÂëadmini--
create certificate c1
encryption by password = 'administrator123'
with subject = 'c1 certificate',
start_date='03/08/2009',
expiry_date = '02/08/2020';
go
2£®´´½¨²âÊÔ±í£¬name×Ö¶ÎΪҪ¼ÓÃܵÄÁУ¬Êý¾ÝÀàÐÍΪvarbinary
×¢Ò⣺¼ÓÃܵÄÀàÐͱØÐëÊÇvarbinary£¬ÒòΪ¼ÓÃܵÄÊý¾ÝÊÇÀàÐÍvarbinary
create table testB(id int identity(1,1),name varbinary(5000))
3£®Ê¹ÓüÓÃܺ¯ÊýÏò²âÊÔ±íÖÐдÈëÒ»Ìõ²âÊÔÊý¾Ý
insert into testB(name)
select encryptbycert(cert_id('c1'),'test')
4£®ÀûÓÃÏÂÃæµÄÓï¾äÀ´ÌáÈ¡¼ÓÃÜÊý¾Ý
select * from testB
5.ÀûÓÃÒÔÏÂÓï¾äÀ´½âÃÜÊý¾Ý
select id ,cast(decryptbycert(cert_id('c1'),name ,
N'administrator123')as varchar(20)) from testB
Íê³ÉÁË
Ïà¹ØÎĵµ£º
sql unionÓ÷¨ºÍsql union allÓ÷¨,sql unionЧÂÊ
1¡¢sql unionÓ÷¨
sql unionÔÚ²éѯÖпÉÒÔ½«Á½¸öSQL Óï¾äµÄ½á¹ûºÏ²¢ÆðÀ´¡£Èç¹ûÕâÑù¿´µÄ»°£¬ UNION ¸ú JOIN ÊÇÏàËƵģ¬Á½¸öÖ¸Á¿ÉÒÔÓɶà¸ö±í¸ñÖÐߢȡ×ÊÁÏ¡£
sql unionµÄÒ»¸öÏÞÖÆÊÇÁ½¸ö SQL Óï¾äËù²úÉúµÄÀ¸Î»ÐèÒªÊÇͬÑùµÄ×ÊÁÏÖÖÀà¡£ÁíÍ⣬µ±ÎÒÃÇÓà UNIONÕâ¸öÖ¸Áîʱ£¬Î ......
дSQLµÄ±Èд.NET³ÌÐòµÄÌåÑéÉϲîÒ»µÈ£¬Ã»ÓÐÖÇÄÜÌáʾ£¬ÐèÒª¼Çס¹Ø¼ü×Ö£¬º¯Êý»òÕß²»¶ÏµØCopy±í×Ö¶ÎÃû£¬×Ô¶¨Ò庯Êý£¬´æ´¢¹ý³ÌÖ®ÀàµÄ¡£²»¹ýÔÚVS2010ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÖÇÄÜÌáʾÁË£¬ÈçÏÂÃ漸·ùͼËùʾ£º ÔÚ±à¼Æ÷ÖУ¬ ÊäÈë Shift + J £¨Ìáʾ£º VS2010 ¿ª·¢¹¤¾ßÖбêµÄÊÇ Ctrl +J ÆäʵӦ¸ÃÊÇ Shift + J £©¾Í¿ÉÒÔ×Ô¶¯´ò¿ªÕâ¸öÖÇÄÜÌá ......
ÔÚ¼¤ÁÒµÄÊг¡¾ºÕù»·¾³Ï£¬ÉÌÈ˶ÔÊг¡»·¾³µÄ°ÑÎպ;ö²ßÖ±½Ó¹Øϵµ½Êг¡µÄÇ÷ÊƺͻúÓö£¬¶Ô¿Í»§ÐèÇóµÄ¿ìËÙÏàÓ¦Äܹ»Õ¼¾¡Êг¡µÄÏÈ»ú¡£ÔÚµ±½ñÉç»áµÄÈÕ³£ÉÌÎñ»î¶¯ÖУ¬ÒÔÍù»ýÀÛµÄÏà¹ØÉÌÒµÊý¾ÝÄܹ»ÎªºóÐøµÄÒµÎñ»î¶¯ÌṩÁ¼ºÃµÄ²Î¿¼ºÍÏòµ¼¡£ÔçÔÚ10ÓàÄêÇ°£¬ÉÌÒµÖÇÄÜ£¨Business Intelligence£¬Ï³ÆBI£©³§É̾ÍÒѾ ......
select a.ClassName,a.CourseName,sum(²»¼°¸ñ) as ²»¼°¸ñ,sum(²î) as ²î,sum(ÖеÈ) as ÖеÈ,sum(ºÃ) as ºÃ ,sum(²»¼°¸ñ)+sum(²î)+sum(ÖеÈ)+sum(ºÃ) as °à¼¶×ÜÈËÊý from (select StudentID,ClassName,CourseName,1 as ²»¼°¸ñ,0 as ²î,0 as ÖеÈ,0 as ºÃ from StudentScore where ScoreRemark='fail' union all
select Stu ......