TSQL: How to swap characters in a string?
<p>I've stored a date as a string in a test DB and the text was stored with the mm and dd swapped.  I have a lot of records and I would like to automate this if possible.  Is there a way in SQL to swap characters based on the position?</p>

<p><a href="https://i.stack.imgur.com/GhxQO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GhxQO.png" alt="enter image description here"></a></p>

<p>Here is the code:</p>

<pre><code>CREATE TABLE #D (
DateAsString varchar (10)
)

INSERT INTO #D (DateAsString)

VALUES 
('20160601'),
('20160127'),
('20160129')

SELECT 
DataAsString

FROM #D
</code></pre>

<p>Thank you.</p>