Is it possible in MS SQL Server 2008 to export database structure into a T-SQL file? I want to export not only tables schema but also primary keys, foreign keys, constraints, indexes, stored procedures, user defined types/functions. Also I don’t want the data to be present in this T-SQL file. Is there a…
Tag: database
getting count from the same column in a mysql table?
I wanted to a count of the same field for different values for example: user{user_id, gender} Gender can have obviously male or female 🙂 i want to get count for all the males and females i.e. but im confused because they come from the same gender coloumn thanks Answer Try this for row wise result: Output: Try…
SQL Server database backup file (.bak ) file gets corrupted
I have been working on a SQL Server database designing since long now and I have observed that when a .bak file is mailed or kept and downloaded from ftp site, it gets corrupted. When I try to restore, it gives me 3013 error code with messsage: “Backup or restore operation terminating abnormally. I trie…
Database Design – Loaner System – Customer loaning multiple items
I am implementing a loaner system and would like find out the most efficient / database standard structure technique to use for the loan records. Let me start with the basics: I have two tables: Customer_Record(id, f_name, l_name, p_number) Loaner_Pool(id, model, serial_n, status) The idea is that the loaner …
CREATE TYPE on MySQL
I couln’t create a new data type on MySQL. Query is given below How can I do that on MySQL Answer You cannot. MySQL doesn’t have user-defined types. (At least, not in current versions.)
Altering column size in SQL Server
How to change the column size of the salary column in the employee table from numeric(18,0) to numeric(22,5) Answer
How to write an “exclusive” query in SQL?
I am going over a past paper for a database course I am taking and I am stuck on an SQL question Here is the schema provided Country(name, capital, area), name is the key People(country, population, children, adult) where country refers to the name in Country, population is the total population, and children …
Mysql queries giving error after upgrading
why this simple query not working. I know it was OK before I upgraded my mysql version. i know there are some syntax changes in new version that I done. but this is simple query no join, but not working. Please help me. EDIT: Upgraded from mysql4 to mysql5 and error is ‘syntax error’ Answer I thin…
Difference between primary key and unique key
I’m using a MySQL database. In which situations should I create a unique key or a primary key? Answer Primary Key: There can only be one primary key constraint in a table In some DBMS it cannot be NULL – e.g. MySQL adds NOT NULL Primary Key is a unique key identifier of the record Unique Key: Can …
How to populate a table’s foreign keys from other tables
I’ve got the following tables, of which translation is empty and I’m trying to fill: The source data to fill translation is a temporary table that I’ve populated from an external CSV file: What I’d like to do is to fill translation with the values from tmp_table. The translated field c…