+ Post New Thread
Results 1 to 3 of 3
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 ...
  1. #1

    Join Date
    Oct 2007
    Posts
    14
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    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.

  2. #2
    rpwillis's Avatar
    Join Date
    Aug 2007
    Location
    SalamanderSoft Ltd
    Posts
    176
    Thank Post
    43
    Thanked 61 Times in 49 Posts
    Rep Power
    26

    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

  3. #3

    Join Date
    Oct 2007
    Posts
    14
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    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:
+ Post New Thread

Similar Threads

  1. ID cards
    By witch in forum General Chat
    Replies: 15
    Last Post: 30th September 2010, 11:10 AM
  2. graphics cards
    By browolf in forum Hardware
    Replies: 12
    Last Post: 5th July 2007, 11:40 AM
  3. Looking for 2 sound cards
    By timbo343 in forum Hardware
    Replies: 6
    Last Post: 7th June 2007, 06:31 PM
  4. no need for wifi cards
    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
  •