¡¾×ª¡¿+¡¾Ô¡¿SQL Server ÈÕÆÚº¯Êý£ºÄ³ÌìÊÇÐÇÆÚ¼¸
ÒªµÃµ½Ä³Ò»ÌìÊÇÐÇÆÚ¼¸£¬ÐèÒªÓõ½ SQL Server ÖеÄÈÕÆÚº¯Êý£ºdatename()¡£ ½ñÌìÊÇÐÇÆÚ¼¸£¬Àý×Ó 1£º 1: set language N'English'
2: select datename(weekday, getdate())
3:
4: Wednesday
½ñÌìÊÇÐÇÆÚ¼¸£¬Àý×Ó 2£º
1: set language N'Simplified Chinese'
2: select datename(weekday, getdate())
3:
4: ÐÇÆÚÈý
½ñÌìÊÇÐÇÆÚ¼¸£¬Àý×Ó 3£º
1: set datefirst 1
2: select datepart(weekday, getdate())
3:
4: 3 -- ÐÇÆÚÈý
×¢Ò⣺ÕâÀïÓõ½ÁËÁíÍâÒ»¸ö SQL Server ÈÕÆÚº¯Êý datepart()¡£ ¡°set datefirst 1¡± ±íʾÉèÖÃÒ»ÖܵĵÚÒ»ÌìΪÐÇÆÚÒ»¡£ÔÚÀÏÃÀ£¬ËûÃǵÄÒ»ÖܵĵÚÒ»ÌìÏ°¹ßΪÐÇÆÚÌì¡£ÎÒÃÇ¿ÉÒÔͨ¹ý @@datefirst º¯ÊýµÃµ½µ±Ç°»á»°µÄ datefirst ÉèÖÃÖµ¡£
1: select @@datefirst
2:
3: 1
Äã¿ÉÄÜÓÐÒÉÎÊ£º¡°set language¡± ºóÃæµÄÓïÑÔ²ÎÊýÊÇ´ÓÄÄÀïµÃµ½µÄ£¿¿ÉÒԵõ½ÆäËû¹ú¼ÒÓïÑÔÖеÄÐÇÆÚ¼¸Â𣿵±È»ÊÇ¿ÉÒÔµÄÁË£¬ Çë¿´ÏÂÃ棺
1: select alias, * from master..syslanguages
Èç¹ûÎÒÏëµÃµ½º«ÓïÖеÄÐÇÆÚ¼¸£¬¿ÉÒÔÕâÑù£º
1: set language N'Korean'
2: select datename(weekday, getdate())
ÔÎÄÁ´½Ó£ºhttp://www.sqlstudy.com/sql_article.php?id=2008071601
¡¾Ô¡¿£ºÔÚ datefirst ±äÁ¿ÖµÎª 1ʱ£¬²»¸Ä±ädatefirst ÖµµÄÇé¿öÏ£¬¼ÆËãÐÇÆÚ¼¸µÄ·½·¨£º
¼ÙÉè½ñÌìÐÇÆÚÈý
1: select datepart(weekday,'2010-05-05 10:11:45.650')
·µ»Ø 4
1: select (datepart(weekday,getdate())+6)%8 +(datepart(weekday,getdate())+6)/8
·µ»Ø 3
Ïà¹ØÎĵµ£º
USE master
GO
DECLARE @dbname sysname
SET @dbname='TEST' --Õâ¸öÊÇҪɾ³ýµÄÊý¾Ý¿â¿âÃû
DECLARE @s NVARCHAR(1000)
DECLARE tb CURSOR local FOR
SELECT s='KILL '+CAST(spid AS NVARCHAR)&nbs ......
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
Select
CONVERT(varchar(100), GETDATE(), 1): 05/16/06
Select CONVERT(varchar(100),
GETDATE(), 2): 06.05.16
Select CONVERT(varchar(100), GETDATE(), 3):
16/05/06
Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06
Select
CON ......
ÈçºÎʵÏÖ¶à¸ö¹Ø¼ü×Ö°´ÕÕ²»Í¬ÅÅÐò¹æÔò½øÐÐÅÅÐòÄØ£¿
ORDER BY×Ó¾äÈÃÊý¾Ý¿â¶Ô²éѯ½á¹ûÅÅÐò£¬ORDER BY×Ó¾ä±ØÐë·ÅÔÚ²éѯÓï¾äµÄ½áβ¡£Æä»ù±¾ÓÃ
·¨ÈçÏ£º
SELECT * from Contacts ORDER BY first_name;
Äã¿ÉÒÔ¶Ô¶àÁÐÊý¾ÝÅÅÐò¡£ÓÅÏÈ˳Ðò°´´Ó×óµ½ÓÒÒÀ´Î½µµÍ£¬ËùÒÔ²éѯÓï¾äÖ ......
´Ó¹¦ÄÜÉÏ»®·Ö£¬SQLÓïÑÔ¿ÉÒÔ·ÖΪDDL,DMLºÍDCLÈý´óÀà¡£
1. DDL£¨Data Definition Language£©
Êý¾Ý¶¨ÒåÓïÑÔ£¬ÓÃÓÚ¶¨ÒåºÍ¹ÜÀí SQL Êý¾Ý¿âÖеÄËùÓжÔÏóµÄÓïÑÔ £»
CREATE---´´½¨±í
ALTER---Ð޸ıí
  ......
¶øÕâһƪÖУ¬ÎÒÃǾÍΧÈÆSQLÓÅ»¯À´¿ªÊ¼Õâ´Î½²½â£¬ÎªÊ²Ã´µÚÒ»½²ÒªËµSQLÓÅ»¯£¿ÒòΪÎÒÈÏΪÕâÊdzÌÐòÔ±µÄ»ù±¾¹¦£¬¶øÇÒÒ²ÊÇÎÒÃDZØÐëҪȥÕÆÎյģ¬ËäÈ»ÄãдµÄ SQLÓï¾äÄÜÍê³ÉÏàÓ¦µÄ¹¦ÄÜ£¬µ«ÊÇÄãÊÇ·ñ¿¼ÂǹýÕâЩÓï¾äÅöµ½º£Á¿Êý¾Ý»òÕß±©Á¦·ÃÎÊʱ»á²»»á´øÀ´Ð§ÂʵĴó·ù¶ÈµÄ¼õÂý£¿Ò²ÐíºÜ¶à³ÌÐòÔ±ºÍÎÒÒ»ÑùÔÚÅöµ½ÏµÍ³ÏìÓ¦Ê ......