Try Convert in SQL SERVER 2012

SELECT TRY_CONVERT(INT, 100) AS try1, TRY_CONVERT(INT, 'abc') AS try2;



Select TRY_CONVERT(INT, DocNo) AS try1 from
(
Select '1' as DocNo
Union All
Select 'A' as DocNo
Union All
Select 'B' as DocNo
Union All
Select 'C' as DocNo
) AllDatA


Select max(TRY_CONVERT(INT, DocNo)) AS try1 from
(
Select '1' as DocNo
Union All
Select 'A' as DocNo
Union All
Select 'B' as DocNo
Union All
Select 'C' as DocNo
) AllDatA



Select Isnull(max(TRY_CONVERT(INT, DocNo)),0) + 1 AS try1 from
(

Select 'A' as DocNo
Union All
Select 'B' as DocNo
Union All
Select 'C' as DocNo
) AllDatA

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)