SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
SQL Server reformat adds spaces between N and literal

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
SQL Server reformat adds spaces between N and literal
Author Message
GeneW



Joined: 10 Apr 2012
Posts: 18
Country: United States

Post SQL Server reformat adds spaces between N and literal Reply with quote
I have code that looks like this before reformatting:
Code:
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:
Code:
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6509

Post Reply with quote
Thank you. I'm able to reproduce this issue, will report it as a bug.
Fri Oct 12, 2012 3:10 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
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


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.