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_CitySampleMappings201307182'
go
or
usp_removeDuplicateHotelMapping_test 'tab_CitySampleMappings201307182',’’
go
0 comments:
Post a Comment