如何编写存储过程以按顺序获取表中的列之一 [英] how to write stored procedure for getting one of the column in the table in sequence order

查看:115
本文介绍了如何编写存储过程以按顺序获取表中的列之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生

sir

 i have one table name Register.It contains  three columns
userid 
Firstname 
lastname 

in my front end design i create
two textboxes and one submit button.

My requirement is when iam entering submit button firstname and lastname getvalues from textbox1 and textbox2 but  userid coloumn will get values automatically like that userid0001
                                                userid0002
                                                userid0003
                                                     :
                                                     :
                                                     :
for how many times we click submit button that much of time we get increment in the userid coloumn.
Pls help me

推荐答案

Kranthi,
我真的不明白您的确切要求!
您的意思是将列名称与其值连接起来吗?还是将每行3列的值连接在一起?

将3列的值连接在一起

Hi Krant
I really don''t understand your exact requirement!
Do you mean concatenate column name with its value? or concatenate values of 3 columns together for each row?

To concatenate the values of 3 columns together

DECLARE @tmpTable TABLE (userID VARCHAR(10), Name VARCHAR(10))
INSERT INTO @tmpTable VALUES ('ID1','NAME1')
INSERT INTO @tmpTable VALUES ('ID2','NAME2')

SELECT  userID + Name FROM @tmpTable


据我了解,
您想要为特定用户自动生成ID.
为此,您可以在数据库中使用IDENTITY.
在前端显示时,您可以连接您的ID,例如
userid +(来自数据库的ID).
As far as i Understood,
U want autogenerate ID for a particular user.
For that u can use IDENTITY in your database.
While showing in front end, u can Concatenate ur ID like
userid+(id from database).


我认为您的意思是要对特定列中的值进行排序.
您的qeury应该看起来像这样:
I think you mean you want to order the values in a specific column.
Your qeury should look something like this:
SELECT userid, firstname, lastname FROM mytable ORDER BY userid ASC --ending


您还可以通过另一列进行ORDER BY,或通过用户ID DESC(ending)进行ORDER BY. 也许您正在使用LINQ?也有一个按Asc/Desc排序的命令.

我希望这是您想知道的.祝你好运:)


You could also ORDER BY another column or ORDER BY userid DESC(ending)
Maybe you are using LINQ? That has an Order By Asc/Desc too.

I hope this is what you wanted to know. Good luck :)


这篇关于如何编写存储过程以按顺序获取表中的列之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆