SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to insert empty row


How to insert empty row

Author
Message
ramadesai108
ramadesai108
SSC Eights!
SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)

Group: General Forum Members
Points: 847 Visits: 690
I need to insert empty row in a temp table within a stored procedure. The data types are varchar, varchar, decimal and int. I can enter empty string like '' in varchar, but I do not want to enter null in decimal and int. I want all columns to be blank. How do I do that?

Thanks.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86420 Visits: 45233
Blank for those data types would be null.

That said, if you're planning the 'pattern' of inserting a blank row then updating it to actual values, please reconsider. It can cause huge fragmentation problems as well as being a rather poor design pattern. Just insert the real values.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Mark Eckeard
Mark Eckeard
SSC Veteran
SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)

Group: General Forum Members
Points: 257 Visits: 505
Why not just exclude those fields from the temp table? Do you really need them?

Mark



ramadesai108
ramadesai108
SSC Eights!
SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)

Group: General Forum Members
Points: 847 Visits: 690
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.
Mark Eckeard
Mark Eckeard
SSC Veteran
SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)SSC Veteran (257 reputation)

Group: General Forum Members
Points: 257 Visits: 505
Old Hand,

I've seen size issues when the data in the excel spreadsheet it too large but never too small.

How are you creating the file and how are you opening it?

Mark



Eugene Elutin
Eugene Elutin
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4960 Visits: 5478
CELKO (9/10/2012)
I need to insert empty row in a temp table within a stored procedure.


Where is the DDL? There is no such concept in RDBMS.
...


What kind of concept is missing here?
Why is it a problem to have a temp table with empty rows?
It can be used to build cartesian products, and it's quite easy to populate it, for example:



-- create temp table and populate it with 10 empty rows
SELECT TOP 10 CAST(null AS CHAR(1)) c INTO #t
FROM sys.columns

-- Select each row from MyTable as many times (10) as many empty rows found in #t
SELECT t.*
FROM dbo.MyTable
CROSS JOIN #t




See? A bit of creativity and concept flies. Hehe

However, I am sure it's not what OP does need it for...

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
ramadesai108
ramadesai108
SSC Eights!
SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)

Group: General Forum Members
Points: 847 Visits: 690
I am creating and then opening the excel file in MVC application. If the file is not small, then it opens without problems. But if it is small, it errors out. I tried adding more rows with zero values in decimal and int fields, and the same file opens without any problems. The only problem now is when the users sees zeros, they get confused.
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16272 Visits: 19059
Why don't you send all your values as varchar using cast/convert?
Excel will convert everything that looks like a number to a "number type" and leave text as general.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
ramadesai108
ramadesai108
SSC Eights!
SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)SSC Eights! (847 reputation)

Group: General Forum Members
Points: 847 Visits: 690
Cannot do that because that will require too many changes in the application.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search