Auto generated column in sql server [Resolved]

Posted by Saranya Boopathi under Sql Server on 6/11/2013 | Points: 10 | Views : 922 | Status : [Member] | Replies : 3
How to create userdefined auto generated column in sql server

Saranya Boopathi


Responses

Posted by: Kirthiga on: 6/17/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Saranya,

This may help you
create table #AutoGen( Col varchar(100))

DECLARE @slno int
select @slno =10
DECLARE @i varchar(10),@alter varchar(4000)
SET @i=1
while(@i<=@slno)
begin
select @alter='alter table #AutoGen add Col'+@i+' varchar(100)'
exec (@alter)
set @i=@i+1
end
Select * from #AutoGen


This is not your required output please explain your requirement with example.

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 6/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
www.codeproject.com/Articles/491733/Auto-generated-sequence-number-in-SQL-Server

If this post helps you mark it as answer
Thanks

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 6/11/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

try with this.
http://www.mssqltips.com/sqlservertip/1600/auto-generated-sql-server-keys-with-the-uniqueidentifier-or-identity/
http://www.w3schools.com/sql/sql_autoincrement.asp

Thanks,
Bagesh Kumar Singh

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response