Lets assume a scenario where the Employee table contains information for all the Managers and Users. It will contains the relevant branch codes for each Employee.
Managers will have multiple branch codes and Users will have single branch code.
Sample data will be as shown below.
To achieve this STRING_SPLIT function can be used. This is available from SQL Server 2016 version.
Sample SQL Query is as below
SELECT EmpId, EmpName, value AS BranchCode FROM dbo.Employee CROSS APPLY STRING_SPLIT(BranchCode,',')
The query output is as below
Hope this will be helpful...
Managers will have multiple branch codes and Users will have single branch code.
Sample data will be as shown below.
To achieve this STRING_SPLIT function can be used. This is available from SQL Server 2016 version.
Sample SQL Query is as below
SELECT EmpId, EmpName, value AS BranchCode FROM dbo.Employee CROSS APPLY STRING_SPLIT(BranchCode,',')
The query output is as below
Hope this will be helpful...
No comments:
Post a Comment