IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_g_1customer]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_g_1customer]
GO
create procedure [dbo].[mps_g_1customer](
@cmpid int,
@cctag int,
@ccid bigint
)
as
begin
set nocount on
declare @tbname varchar(50)
declare @dbname varchar(50)
declare @fkey   varchar(50) 
exec sys_sql_getTableNamePk @cmpid,'cst',@cctag,0,@tbname output,@fkey output ,@dbname output 
declare @sql nvarchar(4000) 
set @sql = 'select * from '+@dbname+@tbname+' where cc_id='+LTRIM(rtrim(str(@ccid)))  
execute(@sql) 
set nocount off
end