Check the SQL Server database & table size [duplicate] - c#

This question already has answers here:
Determine SQL Server Database Size
(8 answers)
Closed 9 years ago.
How can one check the SQL Server database and table size (in MB) using C#?

Have you looked at the sp_spaceused stored procedure?
Just execute it with DBName.Tablename.
Here is the MSDN Link

Related

What datatype in C# should I use if mapping a database column of type Timestamp? [duplicate]

This question already has answers here:
What does a timestamp in T-Sql mean in C#?
(4 answers)
Closed 4 years ago.
My client is using Insight.Database for SQL Server ORM, using C# as the client. I have encountered a SQL Server 2017 database datatype 'Timestamp' and I am unsure what the C# entity type should be? I have downloaded the code for the Insight.Database and have globally searched for Timestamp, but results are empty.
Any ideas what datatype in C# would best represent a SQL Server Timestamp datatype?
It would be a byte array as that's what you'd use for varbinary.
https://learn.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-data-type-mappings

Loading data into a temp table? [duplicate]

This question already has answers here:
Temporary table record limit in Sql server
(6 answers)
Closed 8 years ago.
I intend to load data from several temp tables (t_source) located in different databases
and servers into one temp table (t_main) using C# code and SQL server. After that, I want
to write data of t_main into a text file.
My question is that can this cause SQL server to run out of memory (because it will be storing the t_main) ? What is the maximum amount of data that I can store in a temp table of a Sql server 2005 or 2008 database ?
Table size (static or temporary) is only limited by available storage space. They are not stored in memory.
In SQL Server, a temp table has the same storage limits as an ordinary table.
http://msdn.microsoft.com/en-us/library/ms190768.aspx

How can I remove all records from a table? [duplicate]

This question already has answers here:
Entity Framework. Delete all rows in table
(25 answers)
Closed 9 years ago.
I want to delete all records from my SQL Server table. I use LINQ to EF5. Is there anything I can do to do that?
context.Entities.DeleteAllOnSubmit(dc.Entities);

Is there a get-or-create (lazy loading?) idiom in SQL? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Solutions for INSERT OR UPDATE on SQL Server
Check if a row exists, otherwise insert
I'm using SQL Server 2008 R2, C# .NET 4.0 (and LINQ).
I want to get or create a row in a table and then append a string to one of its columns.
I'm wondering if there's a best practice for this kind of idiom, or if SQL offers this out of the box?
Somehow transaction start -> select -> insert or update -> transaction end doesn't seem elegant enough...

How can I check the existence of database [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to check for the existence of a DB?
How can I check the existance of database and if it exist how can I delete it?
Check out this page:
http://akrabat.com/winphp-challenge/retriving-a-list-of-database-from-sql-server/
It tells you how to retrieve a list of databases on an sql-server. After that, I think a
DROP DATABASE ...
should do the trick.

Categories