I am developing a script to automatically discover the schema information for a SQL server table, then generate an insert command on the fly.
I have one problem though - the script will work fine if the key (assuming there is one numeric key field) is an auto-incrementing identity, but will not work if it is a normal int and requires me to specify the value.
I can get around this easily enough, but only if I KNOW what type of field it is first.
So far I am getting the following information about the table:
ISNULL(character_maximum_length,0) AS max_length,
WHERE table_name = 'mytablename'
ORDER BY ordinal_position
I have been searching through the schema for ages and cannot find anything that tells me whether a field is an identity seed or not.
Can anyone help?