August 15, 2011 at 12:57 pm
I am trying to build a script where the user has to input his email and name ann we will build a a record for that user with a unique Id, Is there any way i can accomplish this. I know in oracle we can, can we do this in sql server as well
August 15, 2011 at 1:38 pm
SQLTestUser (8/15/2011)
I am trying to build a script where the user has to input his email and name ann we will build a a record for that user with a unique Id, Is there any way i can accomplish this. I know in oracle we can, can we do this in sql server as well
You could insert the user record into a table with an auto-incrementing IDENTITY column. Or you can assign a guid with each user record using NEWID() or NEWSEQUENTIALID().
August 15, 2011 at 1:46 pm
Are you looking for a way to have sql server pop an input box to capture this email? If so, there is no visual component of SQL server. That would have to be in your front end. The identity property of an int (or bigint) field is by far the easiest way to just assign a number to a new record. If you want it to be unique you will need to make it either the primary or set a unique constraint on the column.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply