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

  • Home
  • SEARCH
  • 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 9180169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:58:48+00:00 2026-06-17T17:58:48+00:00

I have a database table that was imported from a csv file which had

  • 0

I have a database table that was imported from a csv file which had NULL in it, so that when it was imported instead of fields being NULL they contain the string value 'NULL'.

The CSV file is to big to open in a text editor to edit out all of the NULL so I am trying to create a SQL query to update each column of the table.

So far I have this

Alter PROCEDURE [dbo].[sp_fixnulls]
     @column nvarchar(100) 
AS
BEGIN
     SET NOCOUNT ON;
     UPDATE my_table
     SET @column=''
     WHERE @column = 'NULL'
END 

---------------

sp_fixnulls (SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME  ='my_table')

but this is not working. I get the error message

Msg 201, Level 16, State 4, Procedure sp_fixnulls, Line 0
Procedure or function ‘sp_fixnulls’ expects parameter ‘@column’, which was not supplied.

  • 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-06-17T17:58:49+00:00Added an answer on June 17, 2026 at 5:58 pm

    @column is a variable. It cannot dynamically swap out its contents into SQL. You need to use TSQL to accomplish this, whereby you generate the SQL into a string then execute it. Such as:

    DECLARE @sql VARCHAR(MAX)
    SET @sql = '
    UPDATE my_table
    SET ' + @column + '=''''
    WHERE ' + @column + ' = ''NULL''
    '
    
    EXEC (@sql) -- don't forget the parentheses
    

    A small note that my code sets the column to empty string, which is NOT the same as NULL. I went with your existing example. If you want NULL, then

    SET ' + @column + '= NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file (which has data imported from Oracle 10G Database) one
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a database table with a field that I need to read from
We have a database with a table whose values were imported from another system.
I have a database table that stores imported information. For simplicity, its something like:
I have a scenario where data needs to be imported from a CSV file
I have just imported a database table from a previous site, and one of
I have a database table that has a Unique Key constraint defined to avoid
I have a database table that is a dictionary of defined terms -- key,
that my problem: I have database table like that: id (AI) market_id 1 6

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.