Create your query as usewal and pass parameters in a querys
DECLARE @Query NVARCHAR(max)
DECLARE @Parameters NVARCHAR(max)
SET @Query = N'Select * from dbSeminar.dbo.indigo_tech Where Gender = @Gender And EmpGroup = @EmpGroup And FirstName = @FirstName'
SET @Parameters = N'@Gender varchar(3),@EmpGroup int,@FirstName varchar(25)'
EXECUTE sp_executesql @Query, @Parameters, @Gender = 'M' ,@FirstName = 'Murli', @EmpGroup = 1
OR
Exec Sp_executesql N'Select * from Deepak_PC.mydb.dbo.Branch Where RegionID = @RegionID',N'@RegionID int',@RegionID = 1
No comments:
Post a Comment