Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Alternate View/Table 1

Status
Not open for further replies.
Aug 16, 2002
20
US
I need to create a table/view using the data from two columns on an existing table. I don't know whether I should create a table or view or something else altogether. Obviously, I'm very new at this. The existing table looks like:

Station_ID, integer
Station_Code, char(30)
...many other columns

I need to create a table/view that retrieves the above two columns, but chops the Station_Code field to only the first 4 characters. This table/view needs to be accessible from report-writing software like Crystal Reports and it needs to stay up-to-date when the existing/parent table is changed.

Can anyone offer some suggestions?
 
A view will work perfectly for you in this case.
Code:
Create view vw_name as
Select station_id,
Left(station_code,4)
From table

This will give you what looks like a table but you don't ever have to update it, because a view pulls directly from the source table every time it is queried.

Denny

--Anything is possible. All it takes is a little research. (Me)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top