Azaad Abbas

Azaad Abbas

  • NA
  • 221
  • 41.4k

data type converting in database

Feb 19 2015 12:20 AM
Hello All,
               I need to pass any data type value from browser  to below parameter so how ? need to apply condition to '@value'?then how?
 
Create PROCEDURE sp_Get_CustInfoInRecPay
(@ColumnName VARCHAR(50)=null,
@Value VARCHAR(50)=null)
AS
BEGIN
DECLARE @cmd AS NVARCHAR(max)
SET @Value = ''''+@Value+ ''''
SET @cmd = N'SELECT
C_Register.UserId, C_Register.Name, C_Register.UserName, C_Register.MobNo,
Area.AreaName, C_Register.Address, C_Register.CreatedDate, C_Register.Status
FROM C_Register join Area on C_Register.AreaId = Area.AreaId WHERE ' + @ColumnName + ' = ' + @Value
EXEC(@cmd)
END

Answers (10)