September 10, 2012 at 4:26 pm
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.
September 10, 2012 at 5:04 pm
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
September 10, 2012 at 5:23 pm
Why not just exclude those fields from the temp table? Do you really need them?
Mark
September 10, 2012 at 6:30 pm
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.
September 10, 2012 at 6:40 pm
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
September 11, 2012 at 3:39 am
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...
September 11, 2012 at 8:46 am
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.
September 11, 2012 at 9:30 am
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.
September 11, 2012 at 10:34 am
Cannot do that because that will require too many changes in the application.
September 11, 2012 at 10:55 am
ramadesai108 (9/11/2012)
Cannot do that because that will require too many changes in the application.
Why? How are you populating your Excel file?
Are you sure this is the correct approach? I'm not sure that creating larger files is a good practice. Are you sure you can't change that in the options?
Another option would be use an older version of Excel to create the file :hehe:
September 12, 2012 at 10:45 am
Add a column named IgnoreThisRow, and set it to true for empty rows, false for real rows.
September 12, 2012 at 10:49 am
The site is used by over 100,000 users. Version of Excel cannot change.
September 12, 2012 at 1:47 pm
ramadesai108 (9/12/2012)
The site is used by over 100,000 users. Version of Excel cannot change.
There seems to be something fundamentally poorly designed given all the challenges you are facing here. You have a web site with over 100,000 users all locked into a specific version of Excel? You are asking for problems with that.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 12, 2012 at 2:04 pm
How are you generating this excel? via SQL? and getting it by file path to the web? what error are you seeing, exactly ? If you can manage to input lines with 0, can't you input lines with a single space?
I think we need more info on your problem
September 14, 2012 at 10:59 am
Using .Net app to connect to sql and get the data using store proc, creating excel file in the app and opening the file. There are no problems with this process. It is just that when the excel file that is produced is small size, excel does not open the file. This is a known issue and the workaround is to create empty rows in excel so that it increases the file and opens the file without any issues.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply