Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing Table Function from Excel
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 10
Network:
Windows Server 2012 R2
Miscellaneous
Thread ID:
01640618
Message ID:
01640632
Views:
49
>You're right, I used a slightly different approach, but yours would have worked as well. (yeah, I'm now the expert :) ).
>
>
>Public Function Extract(fromDate As Date, toDate As Date, sp As String) As Recordset
>    Dim sql As String
>    sql = "select * from sp_aankopen('" & sqlformatDate(fromDate) & "','" & sqlformatDate(toDate) & "')"
>    Debug.Print sql
>    Set rs = New ADODB.Recordset
>    rs.Open sql, conn, adOpenDynamic, adLockOptimistic, -1
>    Set Extract = rs
>    Set rs = Nothing
>End Function
>
>
>I see now what I did wrong. :)
>
>Many thanks!

Embedding parameters into a sql string is not a good approach. Parameters need to be send as parameters, not part of a string.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform