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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to insert an empty row

Author  Topic 

rama108
Posting Yak Master

115 Posts

Posted - 2012-09-05 : 18:32:48
How to insert an empty row in a table without showing "NULL" in any column?

Thanks.

chadmat
The Chadinator

1974 Posts

Posted - 2012-09-05 : 18:38:01
If it's not null, the what do you mean by empty? What are the columns/datatypes?

-Chad
Go to Top of Page

rama108
Posting Yak Master

115 Posts

Posted - 2012-09-05 : 19:03:49
Data types are varchar, varchar, decimal, decimal and decimal. For the varchar I can use single quotes like '' and it will insert nothing in the coloumn, but for decimal I have to enter zero and I do not want any value for the decimal not even zero. I just want blank in all columns when i insert an empty record.

Thanks.
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-09-05 : 19:12:21
[code]insert into MyTable (v1, v2, d1, d2, d3)
values ('', '', null, null, null)[/code]It doesn't appear that you have a primary key on this table. I suspect that you'll run into trouble because of that ere long.

=================================================
We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry
Go to Top of Page

rama108
Posting Yak Master

115 Posts

Posted - 2012-09-10 : 18:20:01
"NULL" is what I do not want. I want blank in every column. How do I achieve?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-10 : 20:02:30
quote:
Originally posted by rama108

"NULL" is what I do not want. I want blank in every column. How do I achieve?


you cant
as '' is not a valid decimal value

what's purpose of showing it as blank if its decimal value?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

rama108
Posting Yak Master

115 Posts

Posted - 2012-09-10 : 20:30:51
With new security featues of Excel, if an Excel file is small size then one cannot programmatically open the file otherwise it errors out. So if the file size is small, I want to add empty records in stored proc, which will feed the data to excel thru my application. If there are zeros in rows, then the users are getting confused. What could be the solution to this?

Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-11 : 00:48:48
quote:
Originally posted by rama108

With new security featues of Excel, if an Excel file is small size then one cannot programmatically open the file otherwise it errors out. So if the file size is small, I want to add empty records in stored proc, which will feed the data to excel thru my application. If there are zeros in rows, then the users are getting confused. What could be the solution to this?

Thanks.


only way is to cast it to varchar then before you apply blank logic

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-09-13 : 05:00:34
quote:
Originally posted by rama108

How to insert an empty row in a table without showing "NULL" in any column?

Thanks.


You should never do this. Why do you want to do this? If you want to show data in a front end application, do this there. It is easy

Madhivanan

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

- Advertisement -