SQL»ù´¡ÎÊÌâÕûÀí(1)——Äã´ð¶ÔÁ˶àÉÙ£¿
ÔÚ³ÌÐòÖУ¬Êý¾Ý¿â²Ù×÷ÊDZز»¿ÉÉٵIJ¿·Ö£¬ËùÒÔÎÒÃÇÒª±¸×ãÊý¾Ý¿âÏà¹ØÖªÊ¶²ÅÄÜÈ¥Ó¦¸¶³ÌÐòÖгöÏÖµÄÖÖÖÖÎÊÌâ¡£»ùÓÚ´Ë£¬ÎÒÌØµØÔÚ¹úÍâÍøÕ¾¡¢²©¿ÍÉÏÕûÀíÁËһЩÎÊÌ⣬²¢¸½´øÁ˴𰸺ͽâÊÍ¡¢²Î¿¼¡£ÎªÁ˱£Ö¤“ÔÖÔ攣¬ÎҾͱ£ÁôÁËÓ¢ÎÄ¡£´ó¼ÒÒ²À´¿´¿´Äã´ð¶ÔÁ˶àÉÙ£¿
1.SQL Server 2008 Backup
ÌâÄ¿£ºIs it possible to restore a SQL Server 2008 Enterprise Edition compressed backup to a SQL Server 2008 Standard Edition?
´ð°¸£ºyes
½âÊÍ£ºRESTORE from compressed backups on SQL Server 2008 Standard Edition is possible, although the backup compression feature is not supported in SQL Server 2008 Standard Edition.
²Î¿¼£º±¸·ÝѹËõ (SQL Server)
2.Identity
ÌâÄ¿£ºWe want to insert record into table a
create table a (a int identity(1,1))
Which statement will work?
insert into a default values
insert into a values (default)
insert into a values (1)
could not insert explicit for identity column
´ð°¸£ºinsert into a default values
½âÊÍ£ºAn insert statement with "default values" works.
²Î¿¼£ºINSERT
3.Dynamic SQL
ÌâÄ¿£ºSam has to run a query dynamically & get the count in a variable and do some processing based on the count. Which of the following queries will return expected output?
declare @tablevariable varchar(100)
set @tablevariable = 'Employees'
A)
declare @sql varchar(100)
Declare @cnt int
Set @sql = 'Select ' + Convert(varchar(100),@cnt) + ' =count(*) from ' + @tablevariable
Exec (@sql) select @cnt
B)
declare @sql varchar(100)
Declare @cnt int
Set @sql = 'Select count(*) from ' + @tablevariable
@cnt = Exec (@sql) select @cnt
C)
DECLARE @sql nvarchar(4000), @params nvarchar(4000), @count int
SELECT @sql = N' SELECT @cnt = COUNT(*) from dbo.' + quotename(@tablevariable)
SELECT @params = N'@cnt int OUTPUT'
EXEC sp_executesql @sql, @params, @cnt = @count OUTPUT select @count
´ð°¸£ºC
½âÊÍ£ºFor getting a variable as output in a dynamic statement, we need to use sp_executeSQL.
²Î¿¼£ºIntroducing Dynamic SQL
4.T-SQL Output Clause
ÌâÄ¿£ºExecuting the
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃæ£¬ºóÃæ ......
¹ØÓÚPL/SQLÖжԴ洢¹ý³Ìadd debug information
http://space.itpub.net/13129975/viewspace-626245
Èç¹ûʹÓÃPL/SQL DeveloperÖÐÑ¡ÔñÒ»¸ö´æ´¢¹ý³Ìdebugµ«ÓÖdebug²»½øÈ¥£¡
½â¾öÕâ¸öÎÊÌâÊǺܼòµ¥µÄ£¬Ö»ÐèÒªÔÚPL/SQL DeveloperÖÐÑ¡ÔñÒªdebugµÄ´æ´¢¹ý³Ì£¬È»ºóµãÓÒ¼ü£¬ÔÚµ¯³öµÄ²Ëµ¥ÖÐÑ¡Ôñ"Add debug information"ºóÔÙÖ ......
1¡¢INSTR4(string1,string2[,a][,b]) ·µ»Østring1Öаüº¬string2µÄλÖÃaºÍbÊÇÒÔUCS4´úÂëµãΪµ¥Î»¡£
ÒÔÉϺ¯Êý·µ»Østring1Öаüº¬string2µÄλÖᣴÓ×ó±ß¿ªÊ¼É¨Ãèstring1,ÆðʼλÖÃÊÇA¡£Èç¹ûAΪ¸ºÊýÄÇô´ÓÓұ߿ªÊ¼É¨Ãè¡£µÚB´Î³öÏÖµÄλÖý«±»·µ»Ø¡£AºÍBȱʡ¶¼Îª1£¬¼´·µ»ØÔÚ
string1ÖеÚÒ»´Î³öÏÖstring2µÄλÖá£Èç¹ûstring2ÔÚAº ......
×î½üÔÚ×öÒ»¸öÊý¾Ýͳ¼Æ£¬ÒªÇó¶ÔÒ»¸ö±íÖеÄÊý¾Ý°´ÕÕÁ½¸öά¶È³ÊÏÖ£¬Ò²¾ÍÊÇ´«Í³µÄ½»²æ±í
±ÈÈ磬ÓÐÒ»¸öÎÊÌâ±í£¬ÓÐÈý¸ö×ֶΣ¬£¨±êÌâ¡¢ÎÊÌâÀà±ð¡¢ÎÊÌâ״̬£©
ÒªÇó°´ÕÕ²»Í¬µÄÀà±ð£¬·Ö±ðͳ¼Æ´¦¸÷¸ö״̬µÄÎÊÌâÊýÁ¿£¨È磺²úÆ·ÎÊÌâÖÐδ´¦ÀíµÄÊýÁ¿¡¢·þÎñÎÊÌâÖÐÒÅÁôÎÊÌâÊýÁ¿µÈµÈ£©¡£
¾¹ý²éÕҺͳ¢ÊÔ£¬ÖÕÓÚÉú³ÉÁ˽á¹û£¬ÏÖÔÚ·ÖÏí¸ø´ó¼Ò¡£ ......
create table bookitem
(
bookname varchar(80) not null,
book_price Decimal(5,2) not null,
quantity int not null
)
insert into bookitem values('Image Processing',34.95,8)
insert into bookitem values('Signal Processing',51.75,6)
insert into bookitem values('Singal And System',48.5,10)
......