I frequently develop small internet applications using ASP.NET and SQL Server 2005. My databases are always only accessed by one application through an ASP.NET web service or something similar.
When I'm developing an application and moving a database back and forth between my development computer (SQLExpress 2008) and hosted server (SQL Server 2005) invariably I end up getting a hodgepodge of owners/roles/schemas/logins etc that seem to crop up and take control of various pieces of the database.
I only know enough about SQL Server to be dangerous, and I just want to get databases designed, but I invariably have to change the db and end up getting various permissions errors (for example when trying to open a diagram after transferring a db).
Is there a way to simply tell SQL Server Management Studio "Hey, I'm the only guy who's going to use this stupid db, so just let me do it?"
Like some command that sets all of these pieces to 'dbo' or something like that?
I am assuming you are using Windows. Make sure you are connecting to SQL with Windows authentication and give your account Sysadmin permissions. Now everything you create (Create Table tablename, Create View viewname) will automatically have dbo as the owner.
Unfortunatly there is a couple of easy answers to your question, but you are probably not going to like them because they will require you to invest in SQL Server skills.
The first tool you should look at is Visual Studio 2008 Database Developer Edition. This version has management tools you are looking for to manage schemas, users, ... I thinks this is now included with Visual Studio 2008 Development Edition
The second approach is to embrace SQL Server administration and get comfertable with writting DDL scripts. The goal is to get to the point where you can deploy changes to SQL Server in a predicatble manner from your development enviornment to test and ultimatly to production.
The crux of the problem is that you move back and forth the database itself. Databases are surprisingly tightly coupled to their host SQL instance, by the login to user mapping and by other settings as well, like encryption keys, usage of msdb procedures and maintenance plans among other. You could minimize some of the impact by carefully using exlclusively SQL Authentication, but that won't eliminate the problem completely. The real solution is that you should have a deployment script and apply changes to your production database(s) via executing T-SQL script(s) that you have previously tested on your development db, not by moving a db 'back and forth'.
I create all objects specifically specifying I want them created as dbo.
so to create a proc I do
Create Procedure dbo.myprocname
Related
I have a questions regarding databases for ASP.Net 4.0 MVC3 (or 4 Beta).
I'm fairly new to the ASP.net MVC environment, and usage of databases in general.
It's stated that the SQL Server Compact is a local database storage. What does this exactly mean? If I were to use this for my web app, would users be able to "access" this database (e.g. register, login), or would I be the only one with access since the file (.sdf) is "local" and is only in my hard disk?
Let's say I'm coding a library management system which would require storage of alot of stuff in the DB. Would it be better to just use the SQL Server Compact that comes with Visual Studio or should I switch to MySQL or some other databases?
I'm asking because I wanna clear everything up before I step into the world of ASP.Net (and since I'll be dealing with DBs alot in future).
The "local" is relative to where the application code runs, not where the user is. If you're using ASP.NET MVC, the application code runs on the server, to the database has to be on the same server. All users using the web application can use it though since the access is done by the application.
I'd use SQL Server Express for that, version 2008 R2 does have a limit of 10GB per database (not including FILESTREAM data AFAIR) but that is already a lot of data. It's free but uses the same engine as the full SQL Server products, but it has some limitations on database size (as mentioned) and resource usage (parallel processing and memory), for many application it is still a perfect solution though.
No, in this case "local" means that it's contained within the package of the web site itself. You'll want to deploy the database file along with the website (but take care not to overwrite it in future subsequent deployments), of course. But the idea is that the database is a file that you put on the server, not a service installed on the server.
Define "a lot of stuff." I doubt you're going to exceed the capacity of SQL Server Compact, or absolutely require features it doesn't provide. You'll want to compare all of the features available in the various databases. (Size limits, native data types, ease of integration, ease of management and deployment, stored procedures, etc.) Chances are any database will work for you, but you'll have to define your needs in more terms than just "a lot of stuff."
1)
SQL SErver Compact edition is a light weight free, embedded, database engine that enables easy database storage. That means you dont need to install any software in a computer for this database to work. you can simply copy the dll of SQL Server compact edition and put in your bin directory and start using it. No additional setup or security permissions are required for it to run.SQL Server CE Stores database as a files on disk. The file extension will be .sdf You can store SQL CE database files within the \App_Data folder of your ASP.NET Web application
Here is how it looks like in a project.
You can do the same things you did with a standard sql server express instance with SQL CE too. So your users would be able to access the data ( thru your application).
2) SQL Server CE would handle this up to an extend. If you have so much data coming in, you probably want to try something bigger like SQL Server express edition etc.. But the migration is easily doable because it is a miniature version of the real SQL Server Database.
If you are in a shread hosting environment and dont have the ability to install / get access to SQL Server instance, you can go with SQL Server CE as it is file based.
This is a good reading to start with : http://weblogs.asp.net/scottgu/archive/2010/06/30/new-embedded-database-support-with-asp-net.aspx
I'm currently using SQL Server Management Studio.
I have a development database, and access to a live database.
I just want to able to migrate my development tables to the live server.
I'm consulting stack flow first, since I don't want to blow anything up.
If you know what tables you want to migrate and they don't yet exist on the prod server, it's as simple as scripting the table definition, then running the script on the server. If it's more complex than that, I would recommend any number of tools which compare database schemas and automatically generate scripts you can run on the destination server to add/alter/remove what you need. A good freeware one for simple jobs is DBComparer. It's pretty basic. An excellent commercial one are the Sql Tools by Red Gate
We are using SQL Examiner Suite for this, but there are a lot of similar tools.
This is worth a look at - I've used it before and it works well and is very easy: Microsoft SQL Server Database Publishing Wizard http://www.microsoft.com/downloads/en/details.aspx?FamilyId=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en
I've just migrated from Access where I would "write" SQL constantly and quickly using their GUI layout. I'm very new to SQL Server and am puzzled why is there no query GUI in SQL Server. Is it just that much more powerful that a GUI wouldn't be able to address the majority of queries? Or is it like a purist thing where once one is no longer in watered down databases like Access that he or she should just know SQL well enough to write it on the fly. Or am wrong altogether, and there IS a graphical way that most programmers compose SQL?
Sorry for the umbrella question, but I think some theory here would help me understand the big picture better.
I think there is a Query Designer as part of Sql Server Management Studio: see for example SQL Server 2005 Management Studio Query Designer.
The SQL Server is a database server. That it self does not have any editor text or GUI. You can mange it from the console, or any dedicated software that might have or not a query designer.
The main difference between Access and SQL Server or any other database, is that the MS Access is application that store the data in a file, when You close "Access" anything can happen inside the database by it self, while you are using SQL Server it is alway on You only connect to it. That why access have build nice query, report form designers. The SQL Server has totally different job to do and does not need this. With SQL Server we have Sql Server Management Studio, whit serve to global management not only for table creation and query design, there is a lot of background staff going on right there for example user management, rights jobs.
So it is not that SQL Server does not have a query designer, You just don't use proper software to work with it. A power full application is SSMS that ChrisW presented.
Actually there is a GUI-Designer for Views and Queries. Just use the SQL Server Management Studio.
For Example on the "Views" right-click and choose "Add View...". The view GUI is looking very similar to the one in access.
AFAIK about MySQL. Earlier there was the MySQL suite of tools and now there is the MySQL Workbench.
Say what you may, but it's definitely a timesaver.
First off, I believe the query designer in SQL Server Management Studio is probably the equivalent of what you've used in Access. I'm not terribly well-versed in using Access except through code, but I think you can do what you want there (in query designer). I've never found it to be very flexible, so I always end up back in the code itself, but there you go.
My other answer is a little bit off topic (and posted at this point mostly for googlers), but if you're a developer (especially using SQL Server), it probably still applies: Linq to SQL in Visual Studio.
I've been developing against SQL Server databases for about 7 years now, and most of that time has been spent writing the SQL statements out by hand. Last year, I changed jobs and finally had an environment where the databases my programs used were local and didn't change structure. I finally had a good opportunity to begin using Linq!
Linq is an amazingly useful tool!!! I now use it for almost (not quite) all of my database interactions from code.
The basic gist is that you create a graphical database layout in a dbml file. This layout includes tables (or views) as objects and association (PK/FK relationships) as links between the objects. How you set up the associations determines whether that property is a single object or an entity set of that object. Imagine you've got the following:
TABLE (ORDERS) TABLE (CUSTOMERS)
-------------- ----------------
PrimKey
CustomerID --(FK)--> PrimKey
OrderDate CompanyName
Using Linq to SQL, when you run something like the following:
Using db as new DataBaseContext
Dim orders = (From iOrder In db.ORDERS Order By iOrder.Customer.CompanyName).ToList
End Using
You end up with a list of Order objects that each own its corresponding Customer object. You can set this up to have object hierarchies and it pretty much works like you'd expect.
Anyway, it's a fairly big topic and more to get into than is appropriate here, but suffice to say that I think it's a great technology to bridge graphical interaction with true, nitty-gritty code.
I Want Implement a Software by C#.net.I want Use a DataBase Manager Software like Access or SqlLite or etc.My Program Saved Many Data in Local Machine.
I Do Not Want Publish or Move Data to Other Pcs
What DataBase Manager Software Must be Choose?
Not Different DataBase is Free or have a price.
what is the Best DataBase Manager Software to Save many Data in Local Machine?
For sure you are looking for a free database so for that you can use many databases like mysql ,postgresql , and sql server msde or access
but we still have other scenario, if you are going to distribute this application to other pcs so you have to think about deployment and in this case you can eliminate the mysql , postgresql because they depend on servers but msde (it's also server ) is much easier and you can found alot of tutorials how to deploy it with your project
It depends on how much you are expert in database and for what reason you are using it? are you going to need complex queries or it just a storage place for the data ?
if it's complex query i will go for msde for sql server if it's only for saving information may be i will go for access or even xml
Well if you are developing in C# consider using the MSSql Compact Edition. This allows you to create a local database and use it much like SqlLight. However, the support is much better, especially when you using Visual Studio. There you can find it as LocalDatabase under Data when you adding a new item. (Not 100% sure whether it is present on all versions of VS though).
Firefox has an SQLite Manager add-on.
I think the best choice depends on your needs, for example if you must synchronize data with sql server for me the best choise was sql express.
I would vote for SQL Express. You get essentially a scaled down SQL Server that is capable of working with quite a bit of data. SQL Express plays well with Visual Studio and you will be able to take advantage of the System.Data.SqlClient and related namespaces which come with the .NET framework out of the box. They are also better than the Odbc namespaces. Finally, there is a LOT of online support for SQL Express and, as far as I know, SQL Express's flavor of SQL (T-SQL) is the same as that of SQL Server. So should you one day need the flexibility of running with either or (local database, or server database) you will have it. Also, SQL Express is fairly commonly used in the microsoft world so you should be able to find lots of examples, if need by.
TurboDB for .NET from dataweb is a good solution, if you want a powerful engine with stored procedures and professional support from the manufacturer:
http://www.dataweb.de/en/products/dotnet_database.html
Hello,
I'm new here, so sorry, if my question is too basic. However, maybe you have some advice, example, links, which could help me... I'm trying to find something helpfull for few days, but no results as for now.
I'm working in a distributed environment. I have a Oracle server hundreds of miles away and a MS SQL server close to me. I'm writing a application using Visual Web Developer 2008 Express. I need some data from Oracle. It's not worth to query the Oracle server every time i need some data from it. I'd prefer to run some Oracle queries once each night and store results in some local (SQL Server) tables. I assume, I should run queries through standard windows scheduler (Windows Server 2008). I have the basic connectivity - I can open Oracle Database from local Visual Studio.
The questions are:
How to write a query/procedure/function that would get data from Oracle and put them into a SQL Server table (possibly recreated before each query run)?
How can I run such a query from command line (or in other way run from scheduler)
What naming conventions are applicable? In VS I use something like //IP.IP.IP.IP/Name and a user with password.
Thanks for any help or advice.
Regards,
Matteo
I suggest you speak to the DBA's of the Oracle and SQL Server databases, as there may be other considerations you need to bear in mind. (Data Integrity, Security, ownership etc.)
One route you could follow would be to implement DTS (For older databases) or SSIS (for new versions of SQL Server) processes to copy the data across on the schedule you want. (This is pretty much what they were built for.)
How much data are we talking about?
If there is a small quantity that you need to transfer every day, you can write a stupid fetch and insert script in language of your choice.
You only need to search for better solutions if "sync" would take too much resources.
Thanks...
I'm the DBA for the SQL Server, which will serve only for my application. For Oracle I just want to read data and I have enough privileges and agreement with DBA's. Security, ownership and integrity are not an issue for now. I just need some technical advise how to get data from Oracle to MSSQL tables on a schedule.
I use MS SQL Server 2008 Express SP1. I'm very close to solve my problem - I have established connections and everything installed and working. I just don't know, how to run a query, which would get data from Oracle and put into MSSQL, on regular basis, without manual interaction.
I've some experience in programming, but not much in databases (except creating complex SQl queries). Therefore some example or links to detailed description would be helpful. I'm not sure about naming conventions, differences between procedures, functions and queries, command line options to run db automation procedures and so on. I'm also not sure, about which mechanisms or technologies are available in MS SQL Server 2008 Express edition.