473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how we change one data type into another in sql

198 100+
hello expert
can any one help me by providing the way how we can change a column data type from one into another
e,g i have a column which have datatype numeric and i want to change it into Integer
thanks in advance
Dec 15 '07 #1
7 5562
Jim Doherty
897 Expert 512MB
hello expert
can any one help me by providing the way how we can change a column data type from one into another
e,g i have a column which have datatype numeric and i want to change it into Integer
thanks in advance
Look at the CAST and CONVERT functions and reference them in your SQL

typically :

SELECT CONVERT (int,YourNumericfieldname) as MyIntegerField FROM YourTableName

Regards

Jim :)
Dec 17 '07 #2
veer
198 100+
hello expert
i am not understanding your query , is it right syntax
SELECT CONVERT (int,entry) as record FROM output
where entry is the numeric column name and record is the new column name
please check it and correct
thanks




Look at the CAST and CONVERT functions and reference them in your SQL

typically :

SELECT CONVERT (int,YourNumericfieldname) as MyIntegerField FROM YourTableName

Regards

Jim :)
Dec 17 '07 #3
amitpatel66
2,367 Expert 2GB
hello expert
i am not understanding your query , is it right syntax
SELECT CONVERT (int,entry) as record FROM output
where entry is the numeric column name and record is the new column name
please check it and correct
thanks
You can just try out and check if it works isint it?
Post back if it throws any error
Dec 17 '07 #4
veer
198 100+
it shows the syntax error near "as " keyword
and when i use another command
"select convert(int, entry) from output"
it execute but not conver the numeric data type to integer


You can just try out and check if it works isint it?
Post back if it throws any error
Dec 17 '07 #5
amitpatel66
2,367 Expert 2GB
it shows the syntax error near "as " keyword
and when i use another command
"select convert(int, entry) from output"
it execute but not conver the numeric data type to integer
Why dont you try this one:

Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE table1 MODIFY (entry INT);
  2.  
  3.  
But before running above query, you need to empty the table and then run alter command. so take a backup of the data,run the above alter command and reload the data
Dec 17 '07 #6
veer
198 100+
shows the syntax error on modify
is there any probleum with version of sql because i am using sql server 2000



Why dont you try this one:

Expand|Select|Wrap|Line Numbers
  1. ALTER TABLE table1 MODIFY (entry INT);
  2.  
  3.  
But before running above query, you need to empty the table and then run alter command. so take a backup of the data,run the above alter command and reload the data
Dec 17 '07 #7
amitpatel66
2,367 Expert 2GB
shows the syntax error on modify
is there any probleum with version of sql because i am using sql server 2000
Tryh this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER TABLE <table>
  3. { [ ALTER COLUMN <column_name>
  4.   { <new_data_type> [ ( <precision> [ , <scale> ] ) ]
  5.  
  6.  
Dec 17 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bruce | last post by:
Hi, I want to change the datatype of an existing column from char to varbinary. When I run the "Alter Table" statement, I get the following error message - Disallowed implicit conversion...
3
by: rdraider | last post by:
I'm doing a data conversion project, moving data from one SQL app to another. I'm using INSERT INTO with Select and have the syntax correct. But when executing the script I get: Server: Msg...
3
by: Robert | last post by:
Hi, I'm trying to make a slide show, with two frames: on the left frame small thumbnails, and on the right frame the big sized image. Of course when the user clicks on a thumbnail in the left...
11
by: Keith Wilby | last post by:
A97. I want to be able to use code to open change the data type of a field in a table in another database - can this be done? Many thanks. Keith.
1
by: John E. | last post by:
I have a datagrid with one column that is boolean (it is a checkbox column). So that myDataTable.Column..DataType.UnderlyingSystemType == System.Boolean. For printing purposes, I would like to...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
13
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone...
2
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server...
8
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.