Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Null value

Author  Topic 

Gayatri D.Patil
Yak Posting Veteran

58 Posts

Posted - 2008-04-11 : 05:58:23
hello sir,
i want to pass the null value in table.
if i write "NULL"
then Blanck value passed.
i want to pass NULL world.
gayatri

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-11 : 06:07:01
how are you entering it into the table?


declare @t table (col varchar(10))

insert into @t
select null
union all select 'null'



Em
Go to Top of Page

Gayatri D.Patil
Yak Posting Veteran

58 Posts

Posted - 2008-04-11 : 06:39:30
really i don't understand
pls again tell me.
thanku
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-04-11 : 06:42:16
quote:
Originally posted by Gayatri D.Patil

really i don't understand
pls again tell me.
thanku




Please post the query which is used by you
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-11 : 06:43:10
i asked a question of how you are trying to pass this null value into your table.

then posted a sample bit of code for you to run to see the difference between passing NULL and a string of 'NULL'

Em
Go to Top of Page

Gayatri D.Patil
Yak Posting Veteran

58 Posts

Posted - 2008-04-11 : 07:24:56
hello sir,

sir
i want UpdatedBy,UpdateDate
these two fields NULL.


string[] strAryCols = new string[9];
string[] strAryValues = new string[9];

strAryCols[0] = "IndexCode";
strAryCols[1] = "DescrLong";
strAryCols[2] = "DescrShort";
strAryCols[3] = "CtryCode";
strAryCols[4] = "StatusCode";
strAryCols[5] = "CreatedBy";
strAryCols[6] = "CreatedDateTime";
strAryCols[7] = "UpdatedBy";
strAryCols = "UpdateDateTime";

strAryValues[0] = "" + txtIndexCode.Text + "";
strAryValues[1] = "'" + txtDescrLong.Text + "'";
strAryValues[2] = "'" + txtDescrShort.Text + "'";
strAryValues[3] = "" + cmbCntryCode.SelectedValue + "";
strAryValues[4] = "'" + cmbStatus.Text + "'";
strAryValues[5] = "'" + Environment.UserName.ToString() + "'";
strAryValues[6] = DateTime.Now.ToShortDateString();
strAryValues[7] = "Null";
strAryValues = "Null";
try
{

int iRow = objDal.funInsert("Asset.tIndexMaster", strAryCols, strAryValues);
funFillGrid();
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-11 : 07:33:39
Remove the double-quotes around NULL.

strAryValues[7] = null;
strAryValues = null;

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-11 : 09:02:59
Note that NULL is entirely differenct from 'NULL'

select case when NULL='NULL' then 'equal' else 'not equal' end


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Gayatri D.Patil
Yak Posting Veteran

58 Posts

Posted - 2008-04-14 : 06:12:04
quote:
Originally posted by harsh_athalye

Remove the double-quotes around NULL.

strAryValues[7] = null;
strAryValues = null;

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"

Go to Top of Page

Gayatri D.Patil
Yak Posting Veteran

58 Posts

Posted - 2008-04-14 : 06:13:20
sir,
when i remove the double quotes syantax error is come.
gayatri
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-14 : 06:20:46
I assume it is C#.Net. What is the error you get? You should write null (all lowercase).

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -