Diberdayakan oleh Blogger.

Add Table Name And Database Name in Store Procedure

Add Table Name And Database Name in Store Procedure 



alter PROCEDURE usp_removeDuplicateHotelMapping_test
(@tablename varchar(200), @databasename AS NVARCHAR(128)='')
as
DECLARE @execquery AS NVARCHAR(MAX)
SET @execquery = N'UPDATE ' + @databasename + '.[dbo].' + @tablename + ' SET mappedto=b.ID FROM ' + @databasename + '.[dbo].' + @tablename + ' A ' + 'INNER JOIN (SELECT MIN(ID) AS ID,mappedto FROM ' + @databasename + '.[dbo].' + @tablename + ' GROUP BY mappedto) B ON A.mappedto=B.mappedto where a.mappedto>a.id'
EXECUTE sp_executesql @execquery
go


usp_removeDuplicateHotelMapping_test 'tab_CitySampleMappings201507182'
go

or


usp_removeDuplicateHotelMapping_test 'tab_CitySampleMappings201507182',’’
go
Thank you for reading the article about Add Table Name And Database Name in Store Procedure on the blog NEW TECH If you want to disseminate this article on please list the link as the source, and if this article was helpful please bookmark this page in your web browser by pressing Ctrl + D on your keyboard keys.

New articles :

  • Disable T5120 RAID - Cause failure in booting/installing from HD
  • How To Reset The ALOM Password On A Sun Fire T2000
  • Broadband Error Codes
  • Error 651: How to Fix it in Windows 7/8
  • How to Set up a new PPPoE connection on your Windows 7
  • Installing Net-SNMP on Solaris OS
  • How to Upgrade to Perl 5.12.5 on Linux Machine
  • how to get process id attached with particular port in solaris
  • Year 2038 problem
  • Windows exchange Server 2007 installation Steps
  • Related articles :