`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?
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?