I am working on a ASP.NET  project with SQL as back end.(This SQL server is provisioned in cloud using Azure) Part  of my Project, I need to store lot of PDF file (like invoices, Customer Updates) etc. The Number of these PDF files are expected to big in number (5TB may be) Now that I provisioned my SQL server in Azure, I am looking best practices On Where I can store the files?  Can I use Azure Blob? Is it cheaper? or storing in SQL server itself is better (I know backup is a concern) Or any other suggestion?
124034
Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system?  I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server.
56948
I put SQL Server 2012 Standard on a virtual machine (VMWare) which has roughly 98GB of Memory.  Now I checked the query below how much memory is taken by SQL Server.  Microsoft SQL Server 2012 - 11.0.5058.0 (X64)    And see that he ate already 81GB of the memory and the max Memory is set to ~90GB.  Using:  select (physical_memory_in_use_kb/1024)Memory_usedby_Sqlserver_MB,       (locked_page_allocations_kb/1024 )Locked_pages_used_Sqlserver_MB,  (total_virtual_address_space_kb/1024 ) VAS from sys. dm_os_process_memory   SQL Server 2012 Standard should support only 64GB of memory.  Why does my SQL Server eat more than he can? Or is the info incorrect?  Any idea? Is that related to a virtual machine using virtual memory?   I don't know if balloon driver is activated on VM Host...  If you need any more info I will add it.
27084
I am quite new to SQL Server. I would like to collect database disk space metrics for the SQL Server instance as a whole.  I have found a code sample that can collect disk space information per database.  IF OBJECT_ID('DISK.dbo.disk_activity') IS NOT NULL     DROP TABLE disk_activity  CREATE TABLE disk_activity (        servername NVARCHAR(100)     ,  database_id INT PRIMARY KEY     , name NVARCHAR(MAX)     , data_used_size DECIMAL(18,2)     , log_used_size DECIMAL(18,2) )  DECLARE @SQL NVARCHAR(MAX)  SELECT @SQL = STUFF((     SELECT '     USE [' + d.name + ']     INSERT INTO DISK.dbo.disk_activity (servername, database_id, name, data_used_size, log_used_size)     SELECT           (SELECT @@SERVERNAME AS "Server Name") AS SERVER_NAME         , DB_ID()         , DB_NAME()         , SUM(CASE WHEN [type] = 0 THEN space_used END)         , SUM(CASE WHEN [type] = 1 THEN space_used END)     FROM (         SELECT s.[type], space_used = SUM(FILEPROPERTY(s.name, ''SpaceUsed'') * 8. / 1024)         FROM sys.database_files s         GROUP BY s.[type]     ) t;'     FROM sys.databases d     WHERE d.[state] = 0     FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '')  EXEC sys.sp_executesql @SQL   However, I would like to collect the metrics across the entire server, i.e. total disk space allocated for all databases, total disk space used, total disk space free, and percentage of disk space used.  How should I modify the above script or are there other options available?
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?
99722
I've got a C++ program that uses SQLite. I want to store the SQL queries in a separate file -- a plain-text file, not a source code file -- but embed that file in the executable file like a resource.  (This has to run on Linux, so I can't store it as an actual resource as far as I know, though that would be perfect if it were for Windows.)  Is there any simple way to do it, or will it effectively require me to write my own resource system for Linux? (Easily possible, but it would take a lot longer.)
87554
We have 2 servers:  Server A. production (no partitions) Server B. New Server (partitions and compression)  We restored a backup to the new server, partitioned a large table by datetime and turned on compression, and we were happy. Trying to be clever, we turned on replication to update the new server with the latest data on the large table, but that broke the partitioning and compression. We cannot query any old data on the new server, only data from when we turned on replication. The clustered index is the old one, and compression is not on, and no partitions to be seen in SSMS, it's using the PRIMARY filegroup  (same as the current live server is using). On the physical disk, I can see the partition files, and they are still massive with GBs of data, so I know the data is there, but it appears the table has lost the link to it. It appears turning on replication replicated the filegroup side of things. Is there a way to point the table back to partitions and save all the work we did getting it ready for switch over? It's a pretty large database. This one table is 11TB on the production server. SQL Server 2017 Enterprise Edition.
59157
I have a StreamReader object that I initialized with a stream, now I want to save this stream to disk (the stream may be a .gif or .jpg or .pdf).  Existing Code:  StreamReader sr = new StreamReader(myOtherObject.InputStream);    I need to save this to disk (I have the filename). In the future I may want to store this to SQL Server.   I have the encoding type also, which I will need if I store it to SQL Server, correct?
66739
I use RedGate SQL data compare and generated a .sql file, so I could run it on my local machine. But the problem is that the file is over 300mb, which means I can't do copy and paste because the clipboard won't be able to handle it, and when I try to open the file in SQL Server Management Studio I get an error about the file being too large.  Is there a way to run a large .sql file? The file basically contains data for two new tables.
98214
The tempdb of a server (SQL Server 2008) increases to 500GB+ several times every month. Is it possible to find out which SQL statements caused this problem? The problem is usually not caused by create table #temp...; insert into #temp... or select ... into #temp... but complex joins.  The Initial Size of some of the tempdb files is also automatically set to much bigger values every time. How to prevent it?  Sometime the cached plans prevent resizing/shrinking the files. How to find which one hold the tempdb?
27167
I just took a backup of a SQL Server database.  The MDF and LDF files together total around 29 GB, but the .bak file was only 23 GB, about 20% smaller.  My first guess when one version of a set of data is smaller than another version containing the same data would be data compression, but compression usually yields a much better compression ratio than 20%, especially for highly-ordered data (such as database tables.) Also, compressed data can't easily be compressed further, but I know that .bak files can be compressed.  So if the data isn't being compressed, and nothing's being discarded, (because the whole point of making a backup is to be able to restore it to an identical state afterwards,) then what's that 20% that's unaccounted for?
16466
I find that most of my clients are not documenting their databases at all and I find that pretty scary. To introduce some better practice, I would like to know what tools/process people are using.   How do you document your database? (SQL-Server)  What tool do you use?  Documentation Storage Format for database schema/meta-data?   Word documents Excel spreadsheet Plain Text  Documentation process or policies?   I am not talking about reverse engineering / document a existing database, but mainly on the documentation best practices while you develop your system/database.
81584
We're working on migrating some SQL Server VMs to Azure SQL Managed Instances.  We did an initial backup/restore without a problem:  RESTORE DATABASE [xxx]      FROM URL = 'https://&lt;account-name&gt;.blob.core.windows.net/&lt;container-name&gt;/&lt;filename&gt;.bak'   After doing testing, we now need to do a fresh restore from our SQL VMs.  We started doing the same process we initially did but when restoring, we got an error:  Msg 1801, Level 16, State 1, Line 1 Database 'xxx' already exists. Choose a different database name. Msg 3013, Level 16, State 1, Line 1 RESTORE DATABASE is terminating abnormally.   So I tried the WITH REPLACE option.  Unfortunately:  Msg 41901, Level 16, State 2, Line 1 One or more of the options (replace) are not supported for this statement in SQL Database Managed Instance. Review the documentation for supported options.   Reviewing the documentation just tells me that WITH REPLACE isn't available on a Managed Instance.  I can't find any documentation on doing an in-place restore/overwrite of an existing managed instance database.  Am I forced to drop and re-create the database?
83449
We have been using Notes and Attachment to store files related to the record. I also read about Files in salesforce.   How are Files different from Attachment? Are there any limitations or benefits of using Files instead of Attachments?  Are Files available for all editions of Salesforce?  Is it possible to link Files to particular records so they are visible as related list? I tried looking into the content version  but cant seem to find anything to relate to a record
100618
This is a really stupid question, I know, but I have literally zero experience on setting up a website/web app from the server level - I've always used a third party like Arvixe or GoDaddy.  So, I have an Azure VM that I can remote into.  I need to (obviously) set up my website on it.  I've already installed IIS, so I would imagine that the website would go into the      inetpub > wwwroot   folder, right?  Does one usually just copy and paste the files over, FTP, etc.?  What's the typical, accepted way to "upload" your website/web app to your VM?
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?
115362
What is the best way to store a large amount of text in a table in SQL server?  Is varchar(max) reliable?
90248
Assuming you can't use LINQ for whatever reason, is it a better practice to place your queries in stored procedures, or is it just as good a practice to execute ad hoc queries against the database (say, SQL Server for argument's sake)?