views:

25

answers:

2

Does SQL Server allow you to declare stored procedure parameters like this?

@username NVARCHAR

Or do you always have to specify a size like this?

@username NVARCHAR(100)
+2  A: 

If you don't specify a length it will default to 1. Even if that is your intention it is better to be explicit like this:

nvarchar(1)

Edit: I should have pointed out that my previous statement only applies to declarations - if you are using nvarchar in a cast statement and omit a length it will default to 30.

Andrew Hare
A: 

You do not need to specify a length, at least in SQL Server 2005, but it is a good practice to do so.

Jack Marchetti