You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`queryString := 'insert into sch.MyTable(Field1,Field2,Field3) values(@field1,@field2,@field3)'
_, err := sn.DbConn.Exec(queryString,
sql.Named("Field1", myStruct.Field1),
sql.Named("Field2", myStruct.Field2),
sql.Named("Field3", myStruct.Field3)
)`
All fields are strings
Running this multiple times with different sizes of strings result in multiple query plans:
The size of the nvarchar field declaration varies depending on the size of the input string and SQL creates a plan for each variation.
Is there something that I can do that would result in a single query plan for this query?
The text was updated successfully, but these errors were encountered:
AFAIK making this work requires moving away from the Go types to a parameter type that's driver-specific which contains the length/size specification. See microsoft#200
I am using named parameters to build my queries:
`queryString := 'insert into sch.MyTable(Field1,Field2,Field3) values(@field1,@field2,@field3)'
_, err := sn.DbConn.Exec(queryString,
sql.Named("Field1", myStruct.Field1),
sql.Named("Field2", myStruct.Field2),
sql.Named("Field3", myStruct.Field3)
)`
All fields are strings
Running this multiple times with different sizes of strings result in multiple query plans:
`(@field1 nvarchar(4),@field2 nvarchar(16),@field3 nvarchar(16))
INSERT INTO sch.MyTable (Field1,Field2,Field3)
VALUES (@field1, @field2,@field3);`
The size of the nvarchar field declaration varies depending on the size of the input string and SQL creates a plan for each variation.
Is there something that I can do that would result in a single query plan for this query?
The text was updated successfully, but these errors were encountered: