SQL syntax

If I have a column 'Property' in Table 'TableTrial' with value 'EmployeeIDInitial|EmployeeIDFinal', how do I update the value of Property to (2 different values)
1.         'EmployeeIDInitial'
2.         'EmployeeIDFinal'
spiroseAsked:
Who is Participating?
 
Jim HornConnect With a Mentor Microsoft SQL Server Developer, Architect, and AuthorCommented:
<the text left of the pipe>
SELECT LEFT('EmployeeIDInitial|EmployeeIDFinal', CHARINDEX ( '|', 'EmployeeIDInitial|EmployeeIDFinal', 1) - 1)

<text text right of the pipe>
SELECT RIGHT('EmployeeIDInitial|EmployeeIDFinal', LEN('EmployeeIDInitial|EmployeeIDFinal') - CHARINDEX ( '|', 'EmployeeIDInitial|EmployeeIDFinal', 1) )

You can probably take it from there...
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
A field can have only one value, so you'll have to spell out the '2 different values' part.
Do you mean two different records, or two different columns?
0
 
sventhanCommented:
== > to  update the EmpIdInitial value

update yourtable
set property = 'yourvalue'
from dbo.TableTrial
where property='EmployeeIDInitial'


===  > to update the EmpIdFinal Value

update yourtable
set property = 'yourvalue'
from dbo.TableTrial
where property='EmployeeIDInitial'
0
 
spiroseAuthor Commented:
Great- just what I needed
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade.  Good luck with your project.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.