SQL-添加字段处理

1.alter   table   [dbo].[SiteTracks]   drop   constraint   DF__SiteTrack__Audit__47DBAE45
2.ALTER TABLE  [dbo].[SiteTracks] DROP COLUMN  AuditOwnerId
3.alter table [dbo].[Project] add AuditOwner uniqueidentifier default '00000000-0000-0000-0000-000000000000' 
   alter table [dbo].[Project] add AuditType int default('0') not null
  alter table [dbo].[Project] add Note nvarchar(max) null

4.表一对多获取字段

select us.TrueName as '参赛人',us.Userschool as '参赛人学校',productname as '参赛项目', stuff((select  ';' + [dbo].[TeamInfos].username+'-'+

[dbo].[TeamInfos].userschool  from [dbo].[TeamInfos] where [dbo].[TeamInfos].ProductId= Pdu.id

and [dbo].[TeamInfos].isdelete=0 and [dbo].[TeamInfos].teamtype=0  for xml path('')),1,1,'') as '成员姓名-成员学校'
from [dbo].[Products] Pdu left join [dbo].[AspNetUsers] us on  Pdu.createid=us.id

 

posted @ 2018-09-18 10:47  李寒星  阅读(4432)  评论(0编辑  收藏  举报