This could be a duplicate of Include additional columns in a non clustered primary key index.
I have found a script to generate a "create table" ...script. Here is the portion that generates the primary key constraint:
+ isnull((select char(9) + ', constraint [' + k.name + '] primary key (' +
(select stuff((
select ', [' + c.name + '] ' + case when ic.is_descending_key = 1 then 'desc' else 'asc' end
from sys.index_columns ic with (nowait)
join sys.columns c with (nowait) on c.[object_id] = ic.[object_id] and c.column_id = ic.column_id
where ic.is_included_column = 0
and ic.[object_id] = k.parent_object_id
and ic.index_id = k.unique_index_id
for xml path(N''), type).value('.', 'nvarchar(max)'), 1, 2, ''))
+ ')' +
My question: is the ic.is_included_column = 0
condition neccessary? The link above states that a PK cannot include other columns...yet this script uses such a condition. Is it just a mistake? Were there any old versions of sql server where things weren't so?