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

SQLÎÞÏÞ·ÖÀà´æ´¢¹ý³ÌÕûÀí2

Ä£·Â²Î¿¼:¶¯Ò×ÎÞÏÞ·ÖÀà
Óŵã:ËãµÃÉÏÊÇÕæÕýµÄÎÞÏÞ·ÖÀ࣬²»¹ýParentPathÊÇÓоÖÏÞÐÔ,ClassIDÊDZêʶÁÐ×Ô¶¯ÔöÒ».
ȱµã:ÐÂÔö¹ý³ÌÖÐParentID²»´æÔÚ»¹Ã»ÓÐÍêÉÆ£¬»á²åÈëNULLÊý¾Ý.ºóÃæÈý¸ö´æ´¢¹ý³Ì»¹ÔÚ²âÊÔ¡£
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ArticleClass]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ArticleClass]
GO
CREATE TABLE [dbo].[ArticleClass] (
 [ClassID] [int] IDENTITY (1, 1) NOT NULL ,
 [ClassName] [nvarchar] (100) COLLATE Chinese_Taiwan_Stroke_CI_AS NULL ,
 [ParentID] [int] NULL ,
 [ParentPath] [nvarchar] (255) COLLATE Chinese_Taiwan_Stroke_CI_AS NULL ,
 [Depth] [int] NULL ,
 [RootID] [int] NULL ,
 [Child] [int] NULL ,
 [PrevID] [int] NULL ,
 [NextID] [int] NULL ,
 [OrderID] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ArticleClass] ADD
 CONSTRAINT [DF_ArticleClass_ParentID_65E11278] DEFAULT (0) FOR [ParentID],
 CONSTRAINT [DF_ArticleClass_Depth_66D536B1] DEFAULT (0) FOR [Depth],
 CONSTRAINT [DF_ArticleClass_RootID_67C95AEA] DEFAULT (0) FOR [RootID],
 CONSTRAINT [DF_ArticleClass_Child_68BD7F23] DEFAULT (0) FOR [Child],
 CONSTRAINT [DF_ArticleClass_PrevID_69B1A35C] DEFAULT (0) FOR [PrevID],
 CONSTRAINT [DF_ArticleClass_NextID_6AA5C795] DEFAULT (0) FOR [NextID],
 CONSTRAINT [DF_ArticleClass_OrderID_6B99EBCE] DEFAULT (0) FOR [OrderID],
 CONSTRAINT [PK_ArticleClass] PRIMARY KEY  CLUSTERED
 (
  [ClassID]
 )  ON [PRIMARY]
GO
exec sp_addextendedproperty N'MS_Description', N'Ö÷¼ü', N'user', N'dbo', N'table', N'ArticleClass', N'column', N'ClassID'
GO
exec sp_addextendedproperty N'MS_Description', N'Àà±ðÃû³Æ', N'user', N'dbo', N'table', N'ArticleClass', N'column', N'ClassName'
GO
exec sp_addextendedproperty N'MS_Description', N'¸¸ÀàID', N'user', N'dbo', N'table', N'ArticleClass', N'column', N'ParentID'
GO
exec sp_addextendedproperty N'MS_Description', N'¸¸Àà·¾¶', N'user',


Ïà¹ØÎĵµ£º

Sqlº¯Êý´óÈ«

---·µ»Ø±í´ïʽÖÐÖ¸¶¨×Ö·ûµÄ¿ªÊ¼Î»ÖÃ
select charindex('c','abcdefg',1)
---Á½¸ö×Ö·ûµÄÖµÖ®²î
select difference('bet','bit')
---×Ö·û×î×ó²àÖ¸¶¨ÊýÄ¿
select left('abcdef',3)
---·µ»Ø×Ö·ûÊý
select len('abcdefg')
--ת»»ÎªÐ¡×Ö·û
select lower('ABCDEFG')
--È¥×ó¿Õ¸ñºó
select ltrim('   &nbs ......

[SQL]SQLÓï¾ä´óÈ«£¨·ÖÏí£©

--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DRO ......

SQL round()Ïê½â


SQLÖÐround£¨£©º¯ÊýÓ÷¨
SQL round()Ïê½â
roundÓÐÁ½¸öÖØÔØ,Ò»¸öÓдøÓÐÁ½¸ö²ÎÊýµÄ,Ò»¸öÊÇ´øÓÐÈý¸ö²ÎÊýµÄ,
ÿһ¸ö²ÎÊý¶¼ÏàͬÊÇÒª´¦ÀíµÄÊý,
1.´øÓÐÁ½¸ö²ÎÊý.ÿ¶þ¸ö²ÎÊýÊÇСÊýµãµÄ×ó±ßµÚ¼¸Î»»òÓұߵڼ¸Î»,·Ö±ðÓÃÕý¸º±íʾ.×ó±ßΪ¸º,ÓÒ±ßΪ¸º.ΪËÄÉáÎåÈë.
select round(748.585929,-1) 750.000000
select round(748.58592 ......

sql³õ¼¶Óï·¨ ±Ê¼Ç×ܽá

num_field   number(12,2); 
±íʾnum_fieldÊÇÒ»¸öÕûÊý²¿·Ö×î¶à10λ¡¢Ð¡Êý²¿·Ö×î¶à2λµÄ±äÁ¿¡£ 
case.....when Ó÷¨£¨Óëdecode£¨£©×÷ÓúÜÏñ£©
select case zsxm_dm
         when '02' then
          'Ó ......

C#Á¬½ÓACESSʱ£¬sqlÓï¾äÓдí

ÔÚдsqlÓï¾äʱ£¬Ò»°ã¶¼ÊÇÒ»¾ä½â¾ö£¬´ÓÀ´Ã»Ïë¹ý˵£¬°ÑsqlÓï¾ä²ð¿ªÀ´Ð´¡£
ÀýÈçÏÂÃæÕâ¾ä£º  string readstring = "select * from ʵÀý where ʵÀýID='"+eid+"'";
È»ºóÖ´ÐÐ Myconnection();
        DataSet ds = new DataSet();
        OleD ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ