sql-server-express

Best practice to create (on demand) SQL Server 2008 Express databases in C#?

怎甘沉沦 提交于 2019-11-30 13:30:00
问题 The purpose is to handle the user's data (you can call them project, document, file, or whatever) in a brand new SQL Server 2008 Express database. The data are expected to occupy much less space than the 4GB available with the express edition (which is also free to distribute). E.g., each time the user selects File->New command, a new empty database will be created at the specified location. On the other hand, a similar command, File->Open must provide support to retrieve the list of the

LocalDB: How do you delete it?

人盡茶涼 提交于 2019-11-30 10:38:06
问题 Setup: Entity framework code first to new database. Scenario: I'm playing around with EF and I add a bunch of elements to my database. I then change the entity model, and while I know that I could do migrations, I just want to start from scratch and basically wipe the database from the earth. The database used by default was (localdb)\v11.0. My question is: Can I go somewhere and just delete a file, or start some kind of manager to delete that database and start from scratch? 回答1: Just go in

Best practice to create (on demand) SQL Server 2008 Express databases in C#?

馋奶兔 提交于 2019-11-30 07:33:11
The purpose is to handle the user's data (you can call them project, document, file, or whatever) in a brand new SQL Server 2008 Express database. The data are expected to occupy much less space than the 4GB available with the express edition (which is also free to distribute). E.g., each time the user selects File->New command, a new empty database will be created at the specified location. On the other hand, a similar command, File->Open must provide support to retrieve the list of the databases to select one for opening. So, the following issues must be resolved: a) The application must be

How to import .sql file into SQL Server Express

有些话、适合烂在心里 提交于 2019-11-30 05:41:43
I have a plain sql file with some SQL INSERT statements. Is it possible to import it in my local SQL Server Express instance? You can use Management Studio Express edition. You can download the latest version here - which will work against SQL Express 2005, 2008 and 2008 R2. If you don't want to install SSMSE then you can use sqlcmd at a command prompt, e.g. something like this (assuming Windows auth and an instance called "SQLEXPRESS"): sqlcmd -S .\SQLEXPRESS -E -i "C:\path\file.sql" The easiest way would be simply open the file in the Sql Management Studio and run it. Since the target table

How to attach .mdf file to .SQLEXPRESS

一笑奈何 提交于 2019-11-30 05:18:54
问题 Tried this in as connection string connectionString="Server=.\SQLEXPRESS; AttachDbFilename=E:\Database\dnn49.mdf;Database=dnn49; Trusted_Connection=Yes;" but i get an error Unable to open the physical file "E:\Database\dnn49.mdf". Operating system error 5: "5(Access is denied.)". Cannot attach the file 'E:\Database\dnn49.mdf' as database 'dnn49'. What gives? 回答1: You must check the SQL Server Service account has modify permissions over the physical file "dnn49.mdf" , and modify permissions

How to insert into a table with just one IDENTITY column (SQL Express)

只谈情不闲聊 提交于 2019-11-30 01:09:48
问题 Pretty much the same as this question. But I can't seem to get this to work with SQL Server Express in Visual Studio 2008. Same Table layout, One column with identity and primary key. 回答1: INSERT INTO dbo.TableWithOnlyIdentity DEFAULT VALUES This works just fine in my case. How are you trying to get those rows into the database? SQL Server Mgmt Studio? SQL query from .NET app? Running inside Visual Studio in the "New Query" window, I get: The DEFAULT VALUES SQL construct or statement is not

How do I view executed queries within SQL Server Management Studio?

吃可爱长大的小学妹 提交于 2019-11-30 00:01:12
I am new to SQL Server Management Studio and am wondering: is there is a way to see which queries have been run against a database? In the Activity monitor, there is a "Recent Expensive Queries" report but I'm guessing that isn't all of the queries since I'm not seeing the ones I have run. I am running SQL Server Express 2008 v 10.0.1600.22. Use SQL Profiler and use a filter on it to get the most expensive queries. Use the Activity Monitor. It's the last toolbar in the top bar. It will show you a list of "Recent Expensive Queries". You can double-click them to see the execution plan, etc. If

pyodbc insert into sql

假如想象 提交于 2019-11-29 23:56:49
I use a MS SQL express db. I can connect and fetch data. But inserting data does not work: cursor.execute("insert into [mydb].[dbo].[ConvertToolLog] ([Message]) values('test')") I get no error but nothing is inserted into the table. Directly after I fetch the data the inserted row is fetched. But nothing is saved. In MS SQL Server Management Studio the insertion does work. You need to commit the data. Each SQL command is in a transaction and the transaction must be committed to write the transaction to the SQL Server so that it can be read by other SQL commands. Under MS SQL Server Management

LocalDB: How do you delete it?

那年仲夏 提交于 2019-11-29 22:05:21
Setup: Entity framework code first to new database. Scenario: I'm playing around with EF and I add a bunch of elements to my database. I then change the entity model, and while I know that I could do migrations, I just want to start from scratch and basically wipe the database from the earth. The database used by default was (localdb)\v11.0. My question is: Can I go somewhere and just delete a file, or start some kind of manager to delete that database and start from scratch? Filip Gjorgjevikj Just go in command prompt with admin rights and type: //list the instancies sqllocaldb i //stop

Execute stored procedure from a Trigger after a time delay

ⅰ亾dé卋堺 提交于 2019-11-29 20:18:05
问题 I want to call stored procedure from a trigger, how to execute that stored procedure after x minutes? I'm looking for something other than WAITFOR DELAY thanks 回答1: Have an SQL Agent job that runs regularly and pulls stored procedure parameters from a table - the rows should indicate also when their run of the stored procedure should occur, so the SQL Agent job will only pick rows that are due/slightly overdue. It should delete the rows or mark them after calling the stored procedure. Then,