use zx_app_dev select identity(int,1,1) as id,EmpID,DeptIds into # from DatEmployee --select * from # SELECT TOP 200000 id = identity(int,1,1) INTO #t FROM syscolumns a, syscolumns b  

--select EmpID,Cast(DeptID as uniqueidentifier)as deptID from(  SELECT     A.EmpID,     DeptID = SUBSTRING(A.DeptIds, B.ID, CHARINDEX(',', A.DeptIds + ',', B.ID) - B.ID) --这个SUBSTRING在B.ID每一次执行的时候的值是多少?  FROM # A, #t B  WHERE SUBSTRING(',' + a.DeptIds, B.id, 1) = ',' and a.deptids<>''   --这个where后面的检索条件又代表什么含义?  union  Select EmpID,Cast(DeptID as Varchar(50)) DeptID from DatEmployee   drop table #,#t