问题描述
嗨朋友们,
我有两张桌子,
DepartmentMaster字段是
Hi friends,
I have Two tables,
DepartmentMaster fields are
[DeptId] [int] IDENTITY(1,1) NOT NULL,
[DeptName] [varchar](250) NULL,
[Description] [varchar](max) NULL,
和
And
tbl_RFIDReader_M fields are
[ReaderId] [int] IDENTITY(1,1) NOT NULL,
[ReaderName] [varchar](250) NULL,
[OrganizationName] [varchar](250) NULL,
[DepartmentID] [varchar](max) NULL,
[Isdeleted] [varchar](100) NULL,</pre>
和数据
DepartmentMaster
DeptId | DeptName |描述
1 | Dept1 |部门1
2 |部门2 |部门2
3 | Dept3 |部门3
And Data are
DepartmentMaster
DeptId|DeptName|Description
1 | Dept1 | Department1
2 | Dept2 |Department2
3 | Dept3 | Department3
tbl_RFIDReader_M
ReaderId | ReaderName | Org..Name | DepartmentId | IsDeleted
1 | Reader1 | Org1 | 1,2 | 0
2 | Reader2 | Org2 | 2,3 | 0
现在我必须在gridview中显示
ReaderId|ReaderName|Org..Name|DepartmentId|IsDeleted
1 | Reader1 | Org1 | 1,2 | 0
2 | Reader2 | Org2 | 2,3 | 0
now I have to display
tbl_RFIDReader_M
但是我想要名字而不是id
示例
in gridview but i want Names Instead of id
example in
tbl_RFIDReader_M
departmentId在显示中是'1,2'我想要'Dept1,Dept2 'by sp。
所以请帮我制作这个商店的程序。
departmentId is '1,2 ' in Display i want 'Dept1,Dept2' by sp.
so please help me to make store procedure of this.
推荐答案
ReaderID DeptID
1 1
1 2
2 2
2 3
...
这样,您可以使用JOIN轻松地将DeptId转换为名称,并简单地使用常规机制。它会让你的生活变得更加轻松,以后也会更容易。
That way, you can use a JOIN to convert DeptId to the name easily, and simply using the normal mechanisms. And it will make your life a lot, lot easier later on as well.
这篇关于sql server 2008中的sp问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!