Home > Database > Mysql Tutorial > 可以切换表名sqlserver存储过程

可以切换表名sqlserver存储过程

WBOY
Release: 2016-06-07 14:55:04
Original
1090 people have browsed it

原文地址: http://wenwen.soso.com/z/q135587806.htm 无 传表名进去就行了(procName @Table = 'master')CREATE proc procName@Table varchar(50)asdeclare @SqlString varchar(2000)set @SqlString = 'select * form ' + @Tableexec (@SqlString)还可以传

原文地址:  http://wenwen.soso.com/z/q135587806.htm
传表名进去就行了(procName @Table = 'master')
CREATE proc procName
@Table varchar(50)
as
declare @SqlString varchar(2000)
set @SqlString = 'select * form ' + @Table
exec (@SqlString)


还可以传不同的表,不同的字段(procName @Field = '字段名1,字段名2,字段名3', @Table = 'master')
CREATE proc 存储过程名称
@Field varchar(50),
@Table varchar(50)
as
declare @SqlString varchar(2000)
set @SqlString = 'select ' + @Field + 'form ' + @Table
exec (@SqlString)
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template