create database test; create table table1(id bigint,name nvarchar(max)); insert table table1 values(1,'griff'); insert table table1 values(2,'sergey'); insert table table1 values(2,'king'); insert table table1 values(2,'fisher');
id name database 1 griff test 2 sergey test 3 king test 4 fisher test
select *,db_name() [database] from table1
--@table = 'test' CREATE PROCEDURE GetTableData @table VARCHAR(30) AS BEGIN DECLARE @sql VARCHAR(300) SET @sql = 'SELECT *, ' + @table + 'AS TableName FROM ' + @table EXEC(@sql) GO END
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)