MIS Systems Thread, ID Cards with SQL 2005 in Technical; Hi Peeps,
Im working on creating ID cards for the sixth form college i work for.
I have a table ...
-
29th November 2007, 12:53 PM #1
- Rep Power
- 0
ID Cards with SQL 2005
Hi Peeps,
Im working on creating ID cards for the sixth form college i work for.
I have a table holding the student data and a table with staff data. I have created a view for the student table and wish to do so for the staff one, then once i have the 2 views i can create a generic view which the id card will use for populating its data, (name, photo, barcode...etc), but one thing has entered my mind - if the field names for staff and students are different how can i create a generic view.
example:
studentID and teacherCode are unique for the person, but i want to make a view that will put both these in a field called MemberID for instance...
im not very clued up with SQL 2005 so any help is much appreciated.
-
-
IDG Tech News
-
29th November 2007, 07:55 PM #2 Re: ID Cards with SQL 2005
Hi,
You can do this fairly simply by aliasing the columns. If they have different incompatible datatypes you may need to cast one to the other.
A sample script is
create table pupil (studentid int, name varchar(10))
go
create table teacher (staffcode char(2), name varchar(10))
go
insert into pupil(studentid, name) values(1, 'fred')
insert into pupil(studentid, name) values(2, 'sam')
insert into teacher(staffcode, name) values('AA', 'bob')
go
create view members as
select cast(studentid as varchar) as memberid, name from pupil
union
select staffcode as memberid, name from teacher
go
select * from members
go
drop view members
drop table pupil
drop table teacher
go
Richard
-
-
20th December 2007, 10:34 AM #3
- Rep Power
- 0
Re: ID Cards with SQL 2005
I tried wat u sed, but i get a message saying:
'CREATE VIEW' must be the first statement in a query batch.
What does this mean?
-
SHARE: 
Similar Threads
-
By witch in forum General Chat
Replies: 15
Last Post: 30th September 2010, 11:10 AM
-
By browolf in forum Hardware
Replies: 12
Last Post: 5th July 2007, 11:40 AM
-
By timbo343 in forum Hardware
Replies: 6
Last Post: 7th June 2007, 06:31 PM
-
By timbo343 in forum General Chat
Replies: 14
Last Post: 19th February 2007, 01:16 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules