自动生成查询编号 [英] auto generated enquiry noumber

查看:130
本文介绍了自动生成查询编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个名为vwEnquiry的视图,其中有两个同伴
1- strBranchCode varchar(10)和
2- dat查询日期时间

我想生成一个自动生成的代码
它的格式像strBranchCode + year + month + 1,
strBranchCode + year + month + 2,
strBranchCode + year + month + 3等


从datEnquiry中提取年和月的地方



任何机构都可以帮助我在MSSQL中编写此代码吗?


谢谢和问候
Subiya

Hello All,

I have a view named as vwEnquiry in which i have two coloumn
1- strBranchCode varchar(10)and
2- datEnquiry datetime

i want to generate a auto generated code
which has formate like strBranchCode+year+month+1,
strBranchCode+year+month+2,
strBranchCode+year+month+3 etc


where the year and the month will be extract from datEnquiry



can any body help me out to write this code in MSSQL


Thanks and regard
Subiya

推荐答案

Google WITH ROWNUMS,这可能就是您要寻找的自动编号

要获得年份,可以使用DATEPART(year,datEnquiry)和DATEPART(month,datEnquiry),如果要按如下所示将它们连接起来,则可能需要转换它们CAST(DATEPART(year,datEnquiry)as VARCHAR)
Google WITH ROWNUMS, this might be what you''ll be looking for for the auto numbering

To get the year you can use DATEPART(year,datEnquiry) and DATEPART(month,datEnquiry) and you''d probably need to cast these if you going to be concatenating them as follows CAST(DATEPART(year,datEnquiry) as VARCHAR)


您最好的选择是对1/2/3等使用索引,然后从那里建立其余部分,您可以进行选择以将值连接为一个.
Your best bet is to use an index for the 1/2/3 etc and build the rest from there, you can do a select that concatenates values in to one.


这篇关于自动生成查询编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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