开发者

Sql triggers for website

开发者 https://www.devze.com 2023-02-14 00:20 出处:网络
I want to create a trigger for a column, but as i am creating a web form i don\'t want to allow the user to see that id.

I want to create a trigger for a column, but as i am creating a web form i don't want to allow the user to see that id. So when ever a user is added, I want to increment that id as us001, us002, etc. 开发者_StackOverflow中文版How can I do that? I am inserting through c# but don't want to insert into this ID column... it should directly be inserted.


Rather than using a trigger, you could return the userid generated by the database by adding SET @userid = SCOPE_IDENTITY()"; and from this you can create a a string

string generatedUserId = "us" + returnValue.ToString("000");

and then doing an update using the returned value id and the generated user id.

Here is a guide that may give you more of an idea: http://www.davidhayden.com/blog/dave/archive/2006/02/16/2803.aspx

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消