Saturday, February 25, 2012

NULL Records

I am having a problem with our sql database. We keep getting NULL records
in some of our tables. It has not been a problem until today when we got two
NULL records and now I am having a problem deleting them. I am getting an
error saying KEY Column information is insufficient or incomplete. Too many
rows affected by update. I know I am getting this since both of the records
are the same, but I can't find out how to delete them. I tried to write a
script in the QA, but the column that I need to search under is called KEY.
Is this my problem, or could it be something else. Thanks for the help.
DELETE FROM <table_name> WHERE <column_name> IS NULL
<column_name> is the column with the NULL values.
Jacco Schalkwijk
SQL Server MVP
"rick" <rick@.discussions.microsoft.com> wrote in message
news:9D293DE1-2FFC-4231-B9FB-5FB470911D63@.microsoft.com...
>I am having a problem with our sql database. We keep getting NULL records
> in some of our tables. It has not been a problem until today when we got
> two
> NULL records and now I am having a problem deleting them. I am getting an
> error saying KEY Column information is insufficient or incomplete. Too
> many
> rows affected by update. I know I am getting this since both of the
> records
> are the same, but I can't find out how to delete them. I tried to write a
> script in the QA, but the column that I need to search under is called
> KEY.
> Is this my problem, or could it be something else. Thanks for the help.
|||That was the code I was writing, but it kept giving me an error say syntax
was wrong after KEY. Where KEY is the column name. Thanks
"Jacco Schalkwijk" wrote:

> DELETE FROM <table_name> WHERE <column_name> IS NULL
> <column_name> is the column with the NULL values.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "rick" <rick@.discussions.microsoft.com> wrote in message
> news:9D293DE1-2FFC-4231-B9FB-5FB470911D63@.microsoft.com...
>
>
|||Is the column that you have in your table called KEY?
In that case you have to use delimiters around your column name because KEY
is a reserved keyword in T-SQL. Delimiters can be either square brackets
([..]) or double quotes ("..."). For example
DELETE FROM <table_name> WHERE [KEY] IS NULL
Jacco Schalkwijk
SQL Server MVP
"rick" <rick@.discussions.microsoft.com> wrote in message
news:63A09A7D-F4DD-4C8F-8FD8-2FBD9D632B10@.microsoft.com...[vbcol=seagreen]
> That was the code I was writing, but it kept giving me an error say syntax
> was wrong after KEY. Where KEY is the column name. Thanks
> "Jacco Schalkwijk" wrote:
|||Jacco your a hero. That was what was wrong. I just didn't know how to make
SQL think KEY was a column and not something else. So thank you very much.
One last thing. Do you think it is a problem that I have a column named KEY.
Is that why I could be getting these null records. Thanks again.
"Jacco Schalkwijk" wrote:

> Is the column that you have in your table called KEY?
> In that case you have to use delimiters around your column name because KEY
> is a reserved keyword in T-SQL. Delimiters can be either square brackets
> ([..]) or double quotes ("..."). For example
> DELETE FROM <table_name> WHERE [KEY] IS NULL
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "rick" <rick@.discussions.microsoft.com> wrote in message
> news:63A09A7D-F4DD-4C8F-8FD8-2FBD9D632B10@.microsoft.com...
>
>
|||I don't think that the fact that your column is named KEY is the cause of
the NULL values. But you can avoid NULL values and duplicate values
altogether by creating a Primary Key on the column. That will probably cause
the application that tries to insert the NULL values to crash, but then at
least you know where they come from and you can try to fix the code.
Jacco Schalkwijk
SQL Server MVP
"rick" <rick@.discussions.microsoft.com> wrote in message
news:F0F08F87-46BF-472E-8005-66532ACBD8A6@.microsoft.com...[vbcol=seagreen]
> Jacco your a hero. That was what was wrong. I just didn't know how to
> make
> SQL think KEY was a column and not something else. So thank you very
> much.
> One last thing. Do you think it is a problem that I have a column named
> KEY.
> Is that why I could be getting these null records. Thanks again.
> "Jacco Schalkwijk" wrote:
|||Thanks again, I will try that.
"Jacco Schalkwijk" wrote:

> I don't think that the fact that your column is named KEY is the cause of
> the NULL values. But you can avoid NULL values and duplicate values
> altogether by creating a Primary Key on the column. That will probably cause
> the application that tries to insert the NULL values to crash, but then at
> least you know where they come from and you can try to fix the code.
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "rick" <rick@.discussions.microsoft.com> wrote in message
> news:F0F08F87-46BF-472E-8005-66532ACBD8A6@.microsoft.com...
>
>

No comments:

Post a Comment