First, I agree with everyone else, that the normal procedure is that the data type you specify match the type in the database.
In this particular case, what could happen if you pass the value 'Twentyeight" is that you get a conversion error from SQL Server. If you specify the correct data type, you will instead get the conversion error on .NET level. You could argue that is more or less the same.
However, there are other situations. Say that the data type in SQL Server is date
or datetime
and you specify the parameter as NVarChar
rather than Date
or DateTime
. This means that SQL Server will convert the string to date rather than the client. Say that the string is 05/02/2025. Say that the user's regional settings is English (United Kingdom). Then this will be interpreted as 5 February 2025. But in the SQL Server, it is quite likely that the user setting is us_english, because this is the default, and the string will be interpreted as 2 May 2025. You always want date and time strings to be interpreted in the client, according to the user's regional settings.
Another situation is this:
SELECT ... FROM tbl WHERE varcharcol = @x
If you pass @x as NVarChar
, SQL Server will apply its data-precedence rules and convert varcharcol
to nvarchar
. If there is an index on varcharcol
, this will have an effect on performance. If the collation is a Windows collation, the index can still be used as intended, but with some overhead, expect a factor of 2 or 3. If the collation is an SQL collation, the index is not usable, and there will be a scan, and for a large table this can lead to a performance disaster.