How to Store text of 15 to 20 KB file data in blob or as varchar in sql Server?
121095
I have a table with a varchar(max) column that stores text ~4-10KB in size. Data is just being added - never modified, it is a log. My problem is that a table grows too large in size - I would like to keep about 1000000 rows in this table.   I am limited to SQL Server Express and hit the limit on database size. Compression is not available in SQL Server Express and I afraid that Filestream may not be appropriate and the number of files would be too big.   What is the best solution in this case?
31471
How do I get a human-readable file size in bytes abbreviation using .NET?  Example: Take input 7,326,629 and display 6.98 MB
33028
I have a SQL Server table that contains over 20 billion rows, with 13 billion rows in the last partition.  The table is currently partitioned 6 ways by a "Time" field:  2011 2012 2013 2014 2015 2016/2017/2018   The 2016/2017/2018 partition needs to be split into their own partitions so there is a 2016, 2017, 2018 partition.    How can this be done and in the process avoiding a massive log file growth? The database is in Simple Recovery and currently each partition is in a separate file group on its own set of disks.   CREATE TABLE [dbo].[Log](        [RefNo] [nchar](7) NOT NULL,        [DevID] [nvarchar](7) NOT NULL,        [Time] [datetime] NOT NULL,        [summary] [float] NULL,        [staging] [float] NULL,        [position] [float] NULL,  CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED  (        [RefNo] ASC,        [DevID] ASC,        [Time] ASC  )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = ON, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 96)  )
7357
In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the database level)
77077
I was creating a table in SQL Server CE and realized it doesn't support varchar.   Looking this up, I found that "non-Unicode text columns (varchar, char, text) and smallmoney are not supported; although nvarchar, nchar, ntext, and money are supported" as .  Is this true? Why is this, exactly? It would seem that a compact database would support data types that take less bytes to store...I'm assuming it takes more space to save the Unicode characters.   What is the reasoning behind this?
120183
How many records should there be before I consider indexing my sql tables?
49890
I'm currently trying to create a View from a Table that does the following:  Table A ╔═════════════╦═══════════════╗  ║ PART NUMBER ║   FILE NAME   ║ ╠═════════════╬═══════════════╣ ║  PN0001-01  ║      FOO      ║ ║  PN0002-01  ║      BAR      ║ ║  PN0003-01  ║    FOO,BAR    ║ ║  PN0004-01  ║  BAR,FOO,FOB  ║ ╚═════════════╩═══════════════╝   To create  View B ╔═════════════╦═══════════════╗  ║ PART NUMBER ║   FILE NAME   ║ ╠═════════════╬═══════════════╣ ║  PN0001-01  ║      FOO      ║ ║  PN0002-01  ║      BAR      ║ ║  PN0003-01  ║      FOO      ║ ║  PN0003-01  ║      BAR      ║ ║  PN0004-01  ║      BAR      ║ ║  PN0004-01  ║      FOO      ║ ║  PN0004-01  ║      FOB      ║ ╚═════════════╩═══════════════╝   So, essentially, I need to take records from Table A and insert them into View B, where if the record from A has a LIKE '[,]' property, then that field is split into multiple records in B, depending on the number of times the ',' is present, with the text between each ',' being given its own record in View B.
88317
Is declaring VARCHAR size make sense for performance? Is there any difference (in speed) between VARCHAR(50) and VARCHAR(255)? Or defining length is logic/design constraint?
67185
How do I create a file-like object (same duck type as File) with the contents of a string?
74870
By far the most of my data is taken up a column of long strings pointing to the source of the data for each point. I need to keep that. However, it would be neat if CartoDB could use this information (i.e. build the URL) without me providing the full URL, only the relevant ending (and save on the size of the table by not repeating the common part as a long string). Is this doable in their info window?
11380
How to upload a file of size 2GB from Apex? Is there any sobject that I can make use of?
105601
Since varchar anyways allocate space dynamically, my question is whether using varchar(255) be more efficient or save more space compared to using varchar(5000).  If yes, why?
58187
I have a 20,000 line spreadsheet in Apple Numbers, and I need to fill a column with data. I don't want to sit there dragging down the fill handle for thousands of rows.   How can I fill the whole column with a value?
36792
I need to insert 800000 records into an MS Access table. I am using Delphi 2007 and the TAdoXxxx components. The table contains some integer fields, one float field and one text field with only one character. There is a primary key on one of the integer fields (which is not autoinc) and two indexes on another integer and the float field.  Inserting the data using AdoTable.AppendRecord(...) takes > 10 Minutes which is not acceptable since this is done every time the user starts using a new database with the program. I cannot prefill the table because the data comes from another database (which is not accessible through ADO).  I managed to get down to around 1 minute by writing the records to a tab separated text file and using a tAdoCommand object to execute  insert into table (...) select * from [filename.txt] in "c:\somedir" "Text;HDR=Yes"   But I don't like the overhead of this.  There must be a better way, I think.  EDIT:  Some additional information:   MS Access was chosen because it does not need any additional installation on the target machine(s) and the whole database is contained in one file which can be easily copied. This is a single user application. The data will be inserted only once and will not change for the lifetime of the database. Though, the table contains one additional field that is used as a flag to indicate that the corresponding record in another database has been processed by the user. One minute is acceptable (up to 3 minutes would be too) and my solution works, but it seems too complicated to me, so I thought there should be an easier way to do this. Once the data has been inserted, the performance of the table is quite good. When I started planning/implementing the feature of the program working with the Access database the table was not required. It only became necessary later on, when another feature was requested by the customer. (Isn't that always the case?)   EDIT:  From all the answers I got so far, it seems that I already got the fastest method for inserting that much data into an Access table. Thanks to everybody, I appreciate your help.
119820
I have a memory optimised table in SQL Server 2016, with file durability enabled. The table is only 100MB. SQL Server is constantly creating new files on disk, which start off at a few hundred MB, but then grow constantly until the drive runs out of space then they clear down and the process starts again. The files are growing at about 900MB an hour. Running the SQL below shows that all the space is in Precreated Data - so it's not even actually storing large amounts of data, just allocating space to use later.  SELECT state_desc, file_type_desc, COUNT(*) AS [count],    SUM(file_size_in_bytes) / 1024 / 1024 AS [on-disk size MB]    FROM sys.dm_db_xtp_checkpoint_files   GROUP BY state, state_desc, file_type, file_type_desc   ORDER BY state, file_type     File growth on the file group is set to unlimited, so I'm assuming I can set a value on this and stop it growing, but I can't find anything to say why it's allocating so much space in the first place. The data in the table does change very rapidly (a lot of inserts and deletes as the data is constantly processed, but it the data that isn't Precreated never gets over 4GB.  Is there a setting in SQL Server that controls this file precreation? Is it safe to set a limit on the autogrowth for the file group?
74148
Does anyone know of a program, a utility, or some programmatic library, preferably for Linux, that takes an unformatted SQL string and pretty prints it?  For example I would like the following  select * from users where name = 'Paul'   be changed to something like this  select *  from users where    name = 'Paul'   The exact formatting is not important. I just need something to take a large SQL string and break it up into something more readable.
45930
Closely related to  from a few weeks ago, but the answers didn't discuss how to do the . Here's the situation:  We now 15 GB data in a database, but a logging bug in an application ran wild and ran this up to 80GB data giving us DB files around 130GB. We've fixed the bug, cleared out the affected tables, and I'd like to get some of the space back, maybe bring the DB back down to 40GB or so.  The biggest reason I'd like to do this is so that we can more easily restore backups to smaller drives on virtual test instances.  I get it: Shrink is evil, and will fragment both indexes and on-disk file. I'm sold. This is a one time event.  So how can I minimize the pain? Seems like I should:   Use DBCC SHRINKFILE (DataFile1, 40000); to aim for 40 GB.  Immediately use some smart reindexing to reorganize and rebuild indexes Defrag physical disks   Will that appropriately mitigate the side effects of a shrink? Or is this only going to end up on my application for the Evil League of Evil?