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 |
|
Keats
Starting Member
1 Post |
Posted - 2003-06-30 : 05:59:26
|
| Hey everyone!Im working with VB.net in correlation with MS SQL server and im trying to write a function that matches strings with their counterpart in the database. I do this by using a stored procedure that i call from my VB code. The stored procedure looks like this:CREATE PROCEDURE SpecYrkesKod_GetList (@fbdnr [numeric], @avtnr [numeric], @namn [nvarchar])ASSELECT dbo.lr_yrke.yrkkod, dbo.lr_yrke.yrktextFROM dbo.lr_yrkeWHERE (fbdnr = @fbdnr) AND (avtnr = @avtnr) AND yrktext LIKE '%' + @namn + '%'GOwith the intended usage that it should find any string in the DB that contains the characters stored in the namn-variable. However, this syntax returns way to many rows, all of which are not matching. For example if i use the syntax :....AND yrktext = @namn + '%'it manages to find any string starting with the characters in the namn-variable. However, if I use the following:....AND yrktext = '%' + @namnit fails again and return completely irrelevant results. Does anyone know why this is, and how I should write it so that it works ?Thanks/joakimEdited by - merkin on 06/30/2003 07:02:14 |
|
|
atatham
Starting Member
4 Posts |
Posted - 2003-06-30 : 07:22:16
|
| Does replacing like with = make any difference. |
 |
|
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2003-06-30 : 07:28:13
|
What you have done is perfectly fine. I would check your data to be honest.No reason why it shouldn't work.  |
 |
|
|
|
|
|