Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2008, 02:56 PM
Registered User
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create a View "Name" field & Populate

Guys,
I'm trying to create a new field, entitled “Name” and see all employee names from my Employee table using the following format:
LastName, FirstName, jobcode, emailaddress and hire date.

after much effort my code is as follows:

CREATE VIEW 'Name'
AS
SELECT LastName, FirstName, JobID, Email, Hiredate AS Relationship
   FROM 'Name'
Create View 'Name' as Select LastName, FirstName, JobID, Email, Hiredate From EMPLOYEE
Group By LastName, FirstName, JobID, Email, Hiredate Order By LastName

But i'm still getting the following errors:

Msg 111, Level 15, State 1, Line 196
'CREATE VIEW' must be the first statement in a query batch.
Msg 102, Level 15, State 1, Line 199
Incorrect syntax near 'Name'.
Msg 111, Level 15, State 1, Line 200
'CREATE VIEW' must be the first statement in a query batch.

Any assistance is greatly appreciated

 
Old January 24th, 2008, 02:59 PM
Registered User
 
Join Date: Jan 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Update,, Realized i was duplicating my code.. Down to a single error now. I would imagine there is a routine to prevent the first query error??
Thanks..

Code:
CREATE VIEW Names
AS
SELECT LastName, FirstName, JobID, Email, Hiredate AS Relationship
   FROM Names
Group By LastName, FirstName, JobID, Email, Hiredate Order By LastName

Error:
Msg 111, Level 15, State 1, Line 196
'CREATE VIEW' must be the first statement in a query batch.


 
Old February 11th, 2008, 10:28 PM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Hopefully you have figured out your code by now, but if not, I would suggest renaming your view to something different than the table name such as Names_vw.
Good luck!






Similar Threads
Thread Thread Starter Forum Replies Last Post
populate details view or list view non empty rows iinfoque ASP.NET 2.0 Basics 0 March 11th, 2007 06:11 AM
Populate a field Hennie Access VBA 2 September 13th, 2006 12:32 PM
How can I auto-populate two MS Word document field kenn_rosie ASP.NET 1.0 and 1.1 Basics 0 February 15th, 2006 03:59 AM
Populate Auto-Number Field JeffGirard Access 2 August 26th, 2005 06:49 AM
Auto Populate a field ? mar0364 Classic ASP Databases 4 July 9th, 2004 11:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.