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 |
bomerso
Starting Member
2 Posts |
Posted - 2013-03-19 : 09:04:06
|
I am very new to writing views in SQL, so I've quickly run into an problem that I can't figure out.I needed to convert a field from type varchar to type int so that I could link it to another table in Crystal Reports. Here's my view:Create view CR_BillingFilterDataINT asSelect code ,data_type ,convert(int,data) as DATAFrom billing_filter_dataI found that when the DATA field only contains one value, it works fine. But when DATA has multiple values (example 10, 12, 14) it fails to make the conversion. If I understand it correctly, my view is creating this:Code / DataType / DATA1 / 1 / 10,12,14When I need it to create this:Code / DataType / DATA1 / 1 / 101 / 1 / 121 / 1 / 14Any help would be appreciated. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2013-03-19 : 09:36:33
|
comma separated values in a varchar column is a mess...you can use the seach field in the upper right corner to get some ideas on how to handle that i.e. splitting the data... Too old to Rock'n'Roll too young to die. |
|
|
bomerso
Starting Member
2 Posts |
Posted - 2013-03-19 : 13:46:28
|
I have looked through several posts, found some great information (http://www.sqlteam.com/article/parsing-csv-values-into-multiple-rows and http://www.sqlexamples.info/SQL/adv_tally10k.htm ), and concluded that this will take more than than I can commit at the moment. Thanks anyway :) |
|
|
|
|
|
|
|