Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Guid. Can be auto generated?

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2010-09-16 : 18:36:51
Hello,

I have the following table:

CREATE TABLE [dbo].[Profiles]
(
Id INT IDENTITY (1, 1) NOT NULL,
Curriculum VARBINARY (MAX) FILESTREAM NULL,
[Key] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE
) FILESTREAM_ON STORAGE

The column KEY must exist because I am using a FileStream.

So I need to have this column to be unique, correct?

But is it possible to be auto generated instead of the need to create the value in my C# code?

I mean, in this case I don't have any need to define its value in my C# code.

Thank You,
Miguel

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-09-16 : 19:02:38
[code]
CREATE TABLE [dbo].[Profiles]
(
Id INT IDENTITY (1, 1) NOT NULL,
Curriculum VARBINARY (MAX) FILESTREAM NULL,
[Key] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE DEFAULT newid()
) FILESTREAM_ON STORAGE[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-17 : 11:48:11
if you want sequential id you need to use NEWSEQUENTIALID() function.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -