In my database table I have two columns : ProdID and Prod. When I query the database to display the IDs and the product names, I would like to make the result a bit more 'User friendly' by changing the column names to 'Product ID and 'Product'. I do this in the following way :
Open query analyser.
Select the required database.
Select ProdID as 'Product ID', Prod as Products from Inventory
Showing posts with label Query Analyser. Show all posts
Showing posts with label Query Analyser. Show all posts
Sunday, 27 September 2009
Display information in Upper and Lower case from SQL database
In my database table (products) I have a column called items that lists a number of products in sentence case. In order to display them in upper and lower case I do the following :
Open query analyser.
Select the required database.
Upper case
Select upper (item) from products
Lower case
Select lower (item) from products
Open query analyser.
Select the required database.
Upper case
Select upper (item) from products
Lower case
Select lower (item) from products
How do you copy a database table in SQL using code?
Open Query analyser
Select the required database (Use [databasename])
Type :
SELECT * INTO MyNewTable FROM MyTable
e.g SELECT * INTO Customer2 FROM Customer
Select the required database (Use [databasename])
Type :
SELECT * INTO MyNewTable FROM MyTable
e.g SELECT * INTO Customer2 FROM Customer
How do you select all items from a SQL table ?
This is probably the first thing you will ever do with SQL and it's a nice easy one to get you started.
Open query analyser.
Select the required database (This can be done from the drop down menu or by typing "Use [database name"])
Type :
Select * from [table name]
This will now return all the records in the table.
Open query analyser.
Select the required database (This can be done from the drop down menu or by typing "Use [database name"])
Type :
Select * from [table name]
This will now return all the records in the table.
Subscribe to:
Posts (Atom)