June 5, 2015 at 2:37 am
'0' as Account
The source column is varchar(1) but i need this as nvarchar(1).. How can I cast this as NVARCHAR...
Tnx GuruSQL
June 5, 2015 at 2:43 am
CAST(<source column>) as NVarchar(1))
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2015 at 2:47 am
GilaMonster (6/5/2015)
CAST(<source column>) as NVarchar(1))
CAST(('0' as franchiseevendaccount) as NVARCHAR(1))
---
Incorrect syntax near the keyword 'as'.
June 5, 2015 at 2:56 am
CAST('0' as NVARCHAR(20))as Account,
I fix it
June 5, 2015 at 2:56 am
GG_BI_GG (6/5/2015)
GilaMonster (6/5/2015)
CAST(<source column>) as NVarchar(1))CAST(('0' as franchiseevendaccount) as NVARCHAR(1))
---
Incorrect syntax near the keyword 'as'.
Well, yes that's going to give an error. Aliases go after the column definition, not in the middle of a function.
CAST('0' as NVARCHAR(1)) as Franchiseevendaccount
Or, you could skip the cast altogether and define it as a unicode string from the start
N'0' as Franchiseevendaccount
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 5, 2015 at 3:08 am
GilaMonster (6/5/2015)
GG_BI_GG (6/5/2015)
GilaMonster (6/5/2015)
CAST(<source column>) as NVarchar(1))CAST(('0' as franchiseevendaccount) as NVARCHAR(1))
---
Incorrect syntax near the keyword 'as'.
Well, yes that's going to give an error. Aliases go after the column definition, not in the middle of a function.
CAST('0' as NVARCHAR(1)) as Franchiseevendaccount
Or, you could skip the cast altogether and define it as a unicode string from the start
N'0' as Franchiseevendaccount
Never knowing that N syntax 🙂 tnx a lot.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply