Database Operations (vii) Stored procedures

Source: Internet
Author: User

Create a stored procedure

Alter PROCEDURE Zmt_firstpro

@condition nvarchar (1000)

As

Begin

--set NOCOUNT ON declare

@strsql nvarchar (1000)

Set @strsql = ' Select username from trainstudents ' [email protected]

Print (@strsql)

EXEC (@strsql)

End

exec Zmt_firstpro ' where age >8 '

--//Creating a temporary table 1

Alter PROCEDURE Zmt_firstpro

As

Begin

SET NOCOUNT ON select * to #zmt_student from trainstudents

SELECT * FROM #zmt_student

drop table #zmt_student

End

EXEC Zmt_firstpro

Creating a temporary Table 2

Alter PROCEDURE Zmt_firstpro

As

Begin

SET NOCOUNT ON

CREATE TABLE #zmt_student (ID int)

INSERT INTO #zmt_student

Select ID from trainstudents

SELECT * FROM #zmt_student

drop table #zmt_student

End

EXEC Zmt_firstpro

Creating a temporary Table 3

Alter PROCEDURE Zmt_firstpro

@condition nvarchar (1000)

As

Begin

SET NOCOUNT ON

declare @strsql nvarchar (1000)

CREATE TABLE #zmt_student (ID int)

Set @strsql = ' INSERT into #zmt_student ' [email protected]+ ' from trainstudents '

Print (@strsql)

EXEC (@strsql)

SELECT * FROM #zmt_student

drop table #zmt_student

End

EXEC zmt_firstpro ' select id '

Database Operations (vii) 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.