Use the following syntax:
create table programs (
progid int primary key identity(1,1),
name nvarchar(255),
description nvarchar(500),
iconFile nvarchar(255),
installScript nvarchar(255)
)
The primary key
sets the progid
column to be the index column of the table. The identity(1,1)
clause sets the progid
to be an auto-incrementing field, starting at 1 and incrementing by 1 each time. Therefore, the following SQL enters the corresponding rows into programs
:
insert into (name, description, iconfile, installscript)
values ('Name1', 'Test test', 'C:\file\path', 'C:\script\path')
insert into (name, description, iconfile, installscript)
values ('Name2', 'Test 123', 'C:\file\path1', 'C:\script\path2')
------------------------------------------------------------------
progid name description iconfile installscript
------------------------------------------------------------------
1 Name1 Test test C:\file\path C:\script\path
2 Name2 Test 123 C:\file\path1 C:\script\path2
Notice, also, that I used nvarchar
instead of varchar
. This is because nvarchar
uses the Unicode character set, while varchar
uses the ASCII character set. nvarchar
is the recommended usage, since ASCII characters take no additional space in Unicode, but Unicode does allow for internationalization and obscure characters.