SQL Server 2005中的存储过程 [英] stored procedure in sql server 2005

查看:79
本文介绍了SQL Server 2005中的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在存储过程中生成自动增量列值,以及如何将参数从前端传递给like(''A'',字符串长度,表名,表id),并生成A000,A001,A002.. .like那样,如果我们更改前端参数(B,4,tname,idname),则它生成像B000,B001,B002,...那样(发送代码以在存储过程中执行此操作)

how to generate auto increment column value in stored procedure and passing the parameter to the like(''A'',string length,table name,table id) from the front end and generate A000,A001,A002,...like that ,if we change front end parameter (B,4,tname,idname) it generate like B000,B001,B002,...like that ( send the code to perform this in stored procedure)

推荐答案

这篇出色的文章应该为您提供一些想法:
This great article should give you a couple of ideas: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^].

Cheers!

-MRB


要生成自动增量列,您只需使用SQL Server中可用的RANK方法,
我相信ROW_NUMBER (Transact-SQL)排名方法将在这种情况下帮助您生成自动编号列.

链接:
ROW_NUMBER(Transact-SQL)

递归查询还为您提供了在行集中循环并生成自动增量列的选项.

链接:使用公用表表达式的递归查询
To generate auto increment column you can simply use the RANK methods available in SQL Server,
i believe ROW_NUMBER (Transact-SQL) rank methods will help you in this case to generate auto number column.

Link: ROW_NUMBER (Transact-SQL)

The Recursive Queries also give you an option to loop with in the rowset and generate auto increment column.

Link: Recursive Queries Using Common Table Expressions


这篇关于SQL Server 2005中的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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