Simple use of SQL Server stored procedures

Source: Internet
Author: User

--create a stored procedureCreate procTest_proc@date datetime as    Select *  fromT_userwhere TimesbetweenConvert(datetime,CONVERT(varchar(Ten),DATEPART(YYYY,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(MM,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(DD,@date))+ CONVERT(varchar(Ten),' the')) andConvert(datetime,CONVERT(varchar(Ten),DATEPART(YYYY,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(MM,@date))+'-' + CONVERT(varchar(Ten),DATEPART(DD,@date))+ CONVERT(varchar(Ten),'22:00'))Go--Modifying stored ProceduresAlter proctest_1@date datetime as    Select Count(1) fromT_userwhere TimesbetweenCONVERT(varchar(Ten),DATEPART(YYYY,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(MM,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(DD,@date))+  CONVERT(varchar(Ten),' the') andCONVERT(varchar(Ten),DATEPART(YYYY,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(MM,@date))+ '-' + CONVERT(varchar(Ten),DATEPART(DD,@date))+ CONVERT(varchar(Ten),'22:00')Go--Executing stored proceduresexecTest_proc'2012-3-4'--using variables to receive return valuesDeclare @return_value int exec @return_value=Test_1'2012-3-4'Select @return_value

Simple use of SQL Server stored procedures

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.