SQL Server 2008 - Add to string in particular position within name column -


i have been asked job beyond sql skills little , having done research online, cannot quite find write solution done in sql server 2008 , not mysql.

i have table need update specific names adding additional string after point whilst keeping rest of string right intact.

e.g.  current name = 'name - location - 0005' new name = 'name (west) - location - 0005' 

as can see need add text (west), have table lists codes (e.g. 0005) , need link clause update relevant names.

so questions are:

1 - how can update name adding additional text @ set location (5th character), whilst maintaining whatever text right of names

2 - there way can sort of in check code, tried using contains table not full-text indexed. not massive issue can manually create update statement using each row within table, nice know add knowledge base.

with of stuff can achieve this

stuff ( character_expression , start , length , replacewith_expression ) select stuff('name - location - 0005', 5, 0, ' (west)'); 

output name (west) - location - 0005


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -