benlaan / sqlformat

.NET SQL Parser and Formatter Tool and SSMS Plugin
http://sqlformat.benlaan.com
BSD 3-Clause "New" or "Revised" License
73 stars 27 forks source link

sp_execute INSERT looses fields #32

Closed meekys closed 2 years ago

meekys commented 5 years ago

Input: exec sp_executesql N'-- Query INSERT INTO dbo.Table (Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7)',N'@p0 int,@p1 int,@p2 nvarchar(4000),@p3 nvarchar(4000),@p4 datetime,@p5 datetime,@p6 bit,@p7 uniqueidentifier',@p0=1,@p1=1,@p2=NULL,@p3=N'A-User',@p4='2019-01-23 22:41:57.023',@p5='2019-01-23 22:41:57.023',@p6=0,@p7='87EE43C3-1589-41FA-8C17-A9DF00979904'

Output: DECLARE @p0 int, @p1 int, @p2 nvarchar(4000), @p3 nvarchar(4000), @p4 datetime, @p5 datetime, @p6 bit, @p7 uniqueidentifier

SELECT @p0 = 1, @p1 = 1, @p2 = NULL, @p3 = N'A-User', @p4 = '2019-01-23 22:41:57.023', @p5 = '2019-01-23 22:41:57.023', @p6 = 0, @p7 = '87EE43C3-1589-41FA-8C17-A9DF00979904'

INSERT INTO dbo.Table ( ) VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7)

igorpopovio commented 2 years ago

Made a pull request to fix this issue: https://github.com/benlaan/sqlformat/pull/34

@benlaan, please let me know what you think.

Thanks.