Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2010-09-30 : 17:07:02
|
| I have two tables with columns that have a numeric field, and I need to convert them to a numeric text field:FAFSA11=SSN(char(9),null)ISIR11=OriginalSSN(char(9),null)I have a field that is numeric Text field named the following:FAFSA11=SSN(char(9),null)ISIR11=OriginalSSN(char(9),null)I'm having a tough time with the syntax for the ConvertCONVERT ( data_type [ ( length ) ] , expression [ , style ] )Could someone help me with this please. |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-01 : 01:56:42
|
| [code]declare @num numeric(10,2)set @num=9.05select convert(varchar(5),@num)[/code]PBUH |
 |
|
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2010-10-01 : 08:44:07
|
| Thank you! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-10-05 : 06:45:01
|
| This type of formation should be done in front end applicationMadhivananFailing to plan is Planning to fail |
 |
|
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2010-10-06 : 09:24:39
|
| select distinct stud.ssn as systud_ssn, fafsa.ssn as fafsa_ss, isir.originalssn as isir_ssnfrom dbo.systudent as stud left outer join dbo.FaFAFSA11 as fafsa on stud.ssn = fafsa.ssn left outer join dbo.FaISIR11 as isir on fafsa.ssn = isir.originalssnOrder By stud.lastnameNow fafsa_ss and isir_ssn are both char(9), null fieldsI need to either cast or convert them to a field that will allow the SSN number to appear as 000-00-0000.I wrote the following:CAST (Cast(fafsa_ss AS (char(9),null) AS (Varchar(30),null)(Cast(isir_ssn AS (char(9),null) AS (Varchar(30),null)Which I am hoping will allow the fafsa_ss and isir_ssn to appear in the 00-0000-000 format, but I don't know if my code is correct and I don't know where to locate it. I have tried numerous different methods and I have bee researching this for days. Could someone please advise if this Cast function will work and if so where to place it inside the code so that the query will run?Thank you. |
 |
|
|
|
|
|
|
|