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 |
nhamdan
Starting Member
19 Posts |
Posted - 2007-06-10 : 05:57:07
|
Hi All, I have stored procedure that have a query to select from customer table, and i expect the customer name as parameter, so i want to run the query as this: select * from customers where cust_name like '%Nas'But the problem that i cant do it using stored procedure & parameters:for example i made this but it suppose to return results and its not returning:DECLARE @SS CHAR(100) SET @SS = '%Nas'SELECT * FROM BMS_CUSTOMERS WHERE CUST_NAME_A like @ssHow i can update this to return same results as the first statement??Thanks all. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-10 : 06:13:55
|
you are selecting from different table. Is it suppose to be from customers or BMS_CUSTOMERS ?select * from customers where cust_name like '%Nas' SELECT * FROM BMS_CUSTOMERS WHERE CUST_NAME_A like @ss KH |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-06-10 : 06:42:33
|
If your CUST_NAME column is varchar then it won't work if you declare @SS as CHAR because of the space-paddingKristen |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-10 : 07:03:33
|
Good catch  KH |
 |
|
nhamdan
Starting Member
19 Posts |
Posted - 2007-06-10 : 07:24:33
|
Kristen, Thaaaaaaaaaaaaanks alot its working now with your suggestion :).Thanks for others. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-11 : 09:17:53
|
<<How i can update this to return same results as the first statement??>>It wont as they are completely different tables MadhivananFailing to plan is Planning to fail |
 |
|
nhamdan
Starting Member
19 Posts |
Posted - 2007-06-11 : 10:30:04
|
that was a writing mistake ,, ignore it ,, i mean same tables :) |
 |
|
|
|
|
|
|