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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Data Types on Field in View 1

Status
Not open for further replies.

mwake

Programmer
Feb 12, 2004
151
US
I've created a view called Accounts from an Accounts table. The account id field has 20 digits and is a bigint datatype. When I try and create a report using Crystal Reports via ODBC, the Account id field appears as scientific notation. As a result, I want to add a field to my view which uses the data from the account id field, but changes the datatype to text. I'm a Crystal expert but a SQL Server novice, so I'm not sure how to do this. Can someone help me with an insert query??
 
try something like this:

INSERT [INTO] Accounts_View (Accounts_View.AccountID_Field)
SELECT CAST(AccountID_Field AS varchar)
FROM Accounts
[WHERE ...]




 
scrath the cast... if the account field in the view is defined as a char data type then sql server should just convert it I think..

I could be wrong.

@_@

 
Code:
CREATE VIEW view_name
AS

SELECT account_id,
  other_cols,
  CAST(account_id AS varchar) AS account_id_char
FROM table_name

--James
 
Thanks James. It worked great...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top