Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3974204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:32:27+00:00 2026-05-20T04:32:27+00:00

I have a function that accepts one parameter and returns a table/resultset. I want

  • 0

I have a function that accepts one parameter and returns a table/resultset. I want to set a field in a table to the first result of that recordset, passing in one of the table’s other fields as the parameter. If that’s too complicated in words, the query looks something like this:

UPDATE myTable
SET myField = (SELECT TOP 1 myFunctionField
        FROM fn_doSomething(myOtherField)
        WHERE someCondition = 'something')
WHERE someOtherCondition = 'somethingElse'

In this example, myField and myOtherField are fields in myTable, and myFunctionField is a field return by fn_doSomething. This seems logical to me, but I’m getting the following strange error:

'myOtherField' is not a recognized OPTIMIZER LOCK HINTS option.

Any idea what I’m doing wrong, and how I can accomplish this?

UPDATE:

Based on Anil Soman’s answer, I realized that the function is expecting a string parameter and the field being passed is an integer. I’m not sure if this should be a problem as an explicit call to the function using an integer value works – e.g. fn_doSomething(12345) seems to automatically cast the number to an string. However, I tried to do an explicit cast:

UPDATE myTable
SET myField = (SELECT TOP 1 myFunctionField
        FROM fn_doSomething(CAST(myOtherField AS varchar(1000)))
        WHERE someCondition = 'something')
WHERE someOtherCondition = 'somethingElse'

Now I’m getting the following error:

Line 5: Incorrect syntax near '('.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:32:28+00:00Added an answer on May 20, 2026 at 4:32 am

    It seems that (at least in SQL Server 2000) you can’t pass a column value to a table valued function. I had to set up a scalar function to get around this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that accepts a char* as one of its parameters. I
I have been unable to create a Powershell function that accepts more than one
I have a situation that I cannot change: one database table (table A) accepts
I have a function that accepts an anonymous function as an argument and sets
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function that is effectively a replacement for print, and I want
I have a function that automatically exports a table into a CSV file, then
Let's say I have an interface IMyInterface<T> that simply describes one function: public interface
My assignment ask to make a function call readFasta that accepts one argument: the
I have an update function that updates an sql server db table through a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.