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 |
|
tech_1
Posting Yak Master
129 Posts |
Posted - 2012-04-16 : 11:53:46
|
| I am creating or altering a query which selects various fields from a table.I also have a custom SQL CLR function being executed, which returns a table.From the original query, I want to reference or filter through the results returned back from this function (custom SQL CLR) and get the value for that query.Example:SELECT * FROM dbo.CustomFunction AS FuncT SELECT TableA.field1, TableA.field2, TableA.field3, CustomResult = (SELECT resultValue FROM FuncT WHERE date = TableA.field1)makes sense? how can I do this? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-16 : 12:02:57
|
| [code]SELECT TableA.field1, TableA.field2, TableA.field3, CustomResult = resultValue FROM TableACROSS APPLY dbo.CustomFunction()WHERE date = TableA.field1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
tech_1
Posting Yak Master
129 Posts |
Posted - 2012-04-17 : 06:14:08
|
| great thanks.I now have another problem. SQL tries to convert int into nvarchar for some reason.I am storing the data as nvarchar in a column. the data could be numeric/float/whatever but I only ever want to store it as nvarchar.the SQL CLR wrapper I made is returning data as a SqlStringI am then, calling that UDF (that is what the SQL CLR Wrapper is) and inserting data into a tmp table (Again, data types are nvarchar) and finally selecting the value for a row in that tmp table. but then I get the error:Conversion failed when converting the nvarchar value '11.3' to data type int.? |
 |
|
|
tech_1
Posting Yak Master
129 Posts |
Posted - 2012-04-17 : 09:54:50
|
| nevermind. fixed it. it was because I had a case statement for that field but there were different data types for that column |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-17 : 13:23:22
|
| cool------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|