 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
GeneW
Joined: 10 Apr 2012 Posts: 19 Country: United States |
|
SQL Server reformat adds spaces between N and literal |
|
I have code that looks like this before reformatting:
 |
 |
SELECT * INTO #tmp_GridResults_1
FROM (
SELECT N'1' AS [ContactID], N'0' AS [NameStyle], N'Mr.' AS [Title], N'Gustavo' AS [FirstName], NULL AS [MiddleName], N'Achong' AS [LastName] UNION ALL
SELECT N'2' AS [ContactID], N'0' AS [NameStyle], N'Ms.' AS [Title], N'Catherine' AS [FirstName], N'R.' AS [MiddleName], N'Abel' AS [LastName] UNION ALL
SELECT N'3' AS [ContactID], N'0' AS [NameStyle], N'Ms.' AS [Title], N'Kim' AS [FirstName], NULL AS [MiddleName], N'Abercrombie' AS [LastName] UNION ALL
SELECT N'4' AS [ContactID], N'0' AS [NameStyle], N'Sr.' AS [Title], N'Humberto' AS [FirstName], NULL AS [MiddleName], N'Acevedo' AS [LastName] UNION ALL
SELECT N'5' AS [ContactID], N'0' AS [NameStyle], N'Sra.' AS [Title], N'Pilar' AS [FirstName], NULL AS [MiddleName], N'Ackerman' AS [LastName] ) t;
SELECT [ContactID], [NameStyle], [Title], [FirstName], [MiddleName], [LastName]
FROM #tmp_GridResults_1
DROP TABLE #tmp_GridResults_1 |
Which works as written. After reformatting using SQL Assistant, the code looks like this:
 |
 |
SELECT * INTO #tmp_GridResults_1
FROM (
SELECT N '1' AS [ContactID]
,N '0' AS [NameStyle]
,N 'Mr.' AS [Title]
,N 'Gustavo' AS [FirstName]
,NULL AS [MiddleName]
,N 'Achong' AS [LastName] UNION ALL
SELECT N '2' AS [ContactID]
,N '0' AS [NameStyle]
,N 'Ms.' AS [Title]
,N 'Catherine' AS [FirstName]
,N 'R.' AS [MiddleName]
,N 'Abel' AS [LastName] UNION ALL
SELECT N '3' AS [ContactID]
,N '0' AS [NameStyle]
,N 'Ms.' AS [Title]
,N 'Kim' AS [FirstName]
,NULL AS [MiddleName]
,N 'Abercrombie' AS [LastName] UNION ALL
SELECT N '4' AS [ContactID]
,N '0' AS [NameStyle]
,N 'Sr.' AS [Title]
,N 'Humberto' AS [FirstName]
,NULL AS [MiddleName]
,N 'Acevedo' AS [LastName] UNION ALL
SELECT N '5' AS [ContactID]
,N '0' AS [NameStyle]
,N 'Sra.' AS [Title]
,N 'Pilar' AS [FirstName]
,NULL AS [MiddleName]
,N 'Ackerman' AS [LastName]
) t;
SELECT [ContactID]
,[NameStyle]
,[Title]
,[FirstName]
,[MiddleName]
,[LastName]
FROM #tmp_GridResults_1
DROP TABLE #tmp_GridResults_1 |
The added spaces between the ",N" and the quoted literal invalidates the code, causing it to throw errors.
Is there a fix for this?
|
|
Fri Oct 12, 2012 2:42 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Thank you. I'm able to reproduce this issue, will report it as a bug.
|
|
Fri Oct 12, 2012 3:10 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|