1 Replies - 1812 Views - Last Post: 31 July 2010 - 12:33 AM

#1 RandomlyKnighted   User is offline

  • D.I.C Lover
  • member icon

Reputation: 119
  • View blog
  • Posts: 1,384
  • Joined: 14-January 10

Where do I type the T-SQL code in MS SQL Server 2008?

Posted 30 July 2010 - 12:38 PM

Hey everyone, I've been using the SQL Server 2008 for Dummies book. So far I've learned how to create databases, filegroups, add, edit and delete tables, add information to the tables, and now I'm learning about Inner Join and Outer Join.

My book says that I create a new database using this T-SQL code:

CREATE DATABASE students;



Everything I've done so far when creating databases, filegroups, adding and deleting tables, etc. has been by using the Design Explorer and Object Explorer. Do I need to click the add query button and type this code in to create a new database or do I type it in somewhere else? The reason I'm confused on this is because that's not a query at least to my knowledge it's not. So where do I do to actually type the Transact SQL code?

Is This A Good Question/Topic? 0
  • +

Replies To: Where do I type the T-SQL code in MS SQL Server 2008?

#2 Ionut   User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Where do I type the T-SQL code in MS SQL Server 2008?

Posted 31 July 2010 - 12:33 AM

"New query" button opens the T-SQL editor. It's not the best name MS came up with, but there is the place you want to run create, alter, drop statements and select, delete, insert, update statements. You should pay attention though on which database you run your code. Put this
 
use [database_name]
GO


at the top of the query.

Example:
USE master
GO
CREATE DATABASE students




Good luck.

This post has been edited by Ionut: 31 July 2010 - 12:35 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1