locked
Not able to search on the basisof jobtype stored procedure showing error RRS feed

  • Question

  • User345697035 posted


    IF(@JobType is not null and @JobType <> '')
    BEGIN

    SET @sql =@sql + ' OR tejp.JobType Like ''' + cast(@JobType AS nvarchar(100)) + '%'''
    END

    the jobtype is saved in tblemployeerjobpost and wan to search the job type on the candidte job search page 

    Friday, June 17, 2016 7:33 AM

Answers

  • User-2001205625 posted

    Hi ,

    First of all unable to understand the problem of yours please provide some more snippet or the error message .

    If the problem with dynamic sql statements in store procedure then i can suggest you two things . We can execute the dynamic sql statements using the EXEC or SP_executeSql

    1. EXEC

    DECLARE @sqlCommand varchar(1000)
    DECLARE @columnList varchar(75)
    DECLARE @city varchar(75)
    SET @columnList = 'CustomerID, ContactName, City'
    SET @city = '''London'''
    SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = ' + @city
    EXEC (@sqlCommand)

    DECLARE @sqlCommand nvarchar(1000)
    DECLARE @columnList varchar(75)
    DECLARE @city varchar(75)
    SET @columnList = 'CustomerID, ContactName, City'
    SET @city = 'London'
    SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = @city'
    EXECUTE sp_executesql @sqlCommand, N'@city nvarchar(75)', @city = @city

    2.sp_executesql

    With Regards

    Gaurab

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 20, 2016 7:19 AM

All replies

  • User1559292362 posted

    Hi satyam khare,

    Not able to search on the basisof jobtype stored procedure showing error

    Based on your code snippet and description, I'm not sure what causes the issue, could you please provide a bit more information, such as complete stored procedure, detailed error message, related table structure and related data records.

    Best regards,

    Cole Wu

    Monday, June 20, 2016 6:47 AM
  • User-2001205625 posted

    Hi ,

    First of all unable to understand the problem of yours please provide some more snippet or the error message .

    If the problem with dynamic sql statements in store procedure then i can suggest you two things . We can execute the dynamic sql statements using the EXEC or SP_executeSql

    1. EXEC

    DECLARE @sqlCommand varchar(1000)
    DECLARE @columnList varchar(75)
    DECLARE @city varchar(75)
    SET @columnList = 'CustomerID, ContactName, City'
    SET @city = '''London'''
    SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = ' + @city
    EXEC (@sqlCommand)

    DECLARE @sqlCommand nvarchar(1000)
    DECLARE @columnList varchar(75)
    DECLARE @city varchar(75)
    SET @columnList = 'CustomerID, ContactName, City'
    SET @city = 'London'
    SET @sqlCommand = 'SELECT ' + @columnList + ' FROM customers WHERE City = @city'
    EXECUTE sp_executesql @sqlCommand, N'@city nvarchar(75)', @city = @city

    2.sp_executesql

    With Regards

    Gaurab

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 20, 2016 7:19 AM