随笔分类 - SqlServer
摘要:if exists(select * from sys.objects where name='bank')drop table bankCREATE TABLE bank( customerName nvarchar(10), --顾客姓名 [Money] MONEY --当前余额)ALTER TABLE bank --创建表 ADD CONSTRAINT CK_currentMoney CHECK([Money]>=1)INSERT INTO bank(customerName,[Money]) VALUES('张三',1000)INSERT INTO
阅读全文
摘要:-- charindex 查找第一个参数在第二个参数中的位置 第三个参数起始位置--下标是从1开始的 返回0证明没有找到--里面的参数可以由表的字段来直接代替SELECT CHARINDEX('My','My abc Course',1 )select sname,charindex('张',sname,1) as '张出现的位置' from Student--Len 求字符长度select len('aaa')--求每个人的名字长度select sname,len(sname) as '姓名长度'
阅读全文
摘要:--把一个表(或结果集)一次插入到数据库表中insert into class(cname,cDescription)select '01-2','01-21' union allselect '01-3','01-22' union allselect '01-4','01-23' union allselect '01-5','01-24' union allselect '01-6','01-25' union allselect
阅读全文
摘要:proc up_GetPagedData@pi int,--页码@ps int, --页容量@rc float output, --总行数@pc float output--总页数asbegin select @rc=COUNT(cid) from Classes where CIsDel=0--查出总行数select @pc=CEILING(@rc/@ps) -- 算出总页数 CEILING(1.1)=2 floor(1.1)=1select * from (select ROW_NUMBER() over(order by cid) as RNum,* from Classes where
阅读全文
摘要:SELECT ProductName, [UserInfo].UserName, [ReviewContent] ,[ReviewDateTime] ,[ReviewLevel] ,[IsShowd] ,[IPAddress] FROM [B2CRelease].[dbo].[ProductReviewsInfo],[B2CRelease].[dbo].[UserInfo],[B2CRelease].[dbo].[Products] where [ProductReviewsInfo].UserId=[UserInfo].Id and [ProductReviewsInfo].ProductI
阅读全文

浙公网安备 33010602011771号