码迷,mamicode.com
首页 > 数据库 > 详细

SQL

时间:2018-08-23 16:57:46      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:默认   from   code   actual   prope   add   row   自增   table   

alter table LianTong_ContractApproveHistoryModels add CreateUserName nvarchar(max) NULL;

EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N创建人名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NLianTong_ContractApproveHistoryModels, @level2type=NCOLUMN,@level2name=NCreateUserName

--修改字段
ALTER TABLE CisEmployee ALTER COLUMN EmployeeDescription nvarchar(max) NULL;

sp_rename KYX_Employee.PK_KYX_Department_DepartmentName,PK_KYX_Department_DepartmentName1,column

/*ALTER TABLE 删除字段 */
ALTER TABLE TABLE_USER DROP COLUMN TEMP_COL;

--按照字符串长度获取数据
SELECT [CompanyName]
      ,LEN(CompanyName) as lengths
  FROM [dbo].[OOF_Company]
  where LEN(CompanyName) <= 4

--按照字符串长度更新数据
update [dbo].[OOF_Company] set EnumCompanyStatus = 0
  where LEN(CompanyName) <= 4

--查询当天数据
  SELECT * FROMWHERE datediff(day,列名,getdate())=0

  --获取关联表的数据更新
  UPDATE QST_OrderDetail
   SET 
      ActualPrice = (SELECT CurrentPrice FROM QST_Product WHERE ID = QST_OrderDetail.PK_QST_Product_ProductName)

--修改自增的初始值
DBCC CHECKIDENT (TXCC_Assit, RESEED, 100000)

--Values\s(\(N.\w*‘,)

    SELECT [Id]
      ,[Operator]
      ,[Message]
      ,[Result]
      ,[Type]
      ,[Module]
      ,[CreateTime]
  FROM [dbo].[SysLog]
  WHERE CreateTime >= Convert(datetime,2018-05-02 17:20:00, 101)
  and CreateTime <= Convert(datetime,2018-05-02 17:30:00, 101)

  update [GMGood] set [uploaddate] = REPLACE(SUBSTRING([uploaddate],6, 10),.,-) where a=a

--字符串值的长度
      datalength(uploaddate) = 20

--字符串位置
Select CharIndex(a, 1235ab)
--5



SELECT * FROM (select row_number()over(order by uploaddate desc)rownumber,* from GMGood) GMGood1 
WHERE statusupload = 1 and rownumber between 31 and 60

SQL Server 字段设置默认值
1. 如果表字段已经建好
ALTER   TABLE   表名  ADD   CONSTRAINT   DF_TABLEName_FieldName   DEFAULT   1   FOR   字段名
2. 如果表字段没有建
alter table 表名 add 字段名 int default(1)

 

SQL

标签:默认   from   code   actual   prope   add   row   自增   table   

原文地址:https://www.cnblogs.com/Rexcnblog/p/9524343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!