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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-16 : 10:40:55
|
| I want to repair the following, I can't identify what's wrong with this.pp1="17"select * from emp_master where substr(emp_id,1,2)=pp1How to use by this type of select from variable values?Thanks & helps are highly appreciatedParamu @ PARANTHAMAN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 10:43:38
|
| [code]DECLARE @pp1 varchar(2)SET @pp1='17'select * from emp_master where cast(emp_id as varchar(20)) like @pp1 + '%'[/code] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-16 : 11:06:31
|
| Try to give me in single line , will be usefull to call up from vb.netThanksParamu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 11:12:40
|
| its single line. i just declared the variable thats all. the query to use is"select * from emp_master where cast(emp_id as varchar(20)) like " & your pp1 variable in vb.net & "'%'" |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-16 : 11:54:00
|
| Both are giving problemselect * from emp_master where cast(emp_id as varchar(10)) like " & kyprs & "'%'"andDECLARE @pp1 varchar(10) SET @pp1='&kyprs' select * from emp_master where cast(emp_id as varchar(10)) like @pp1 + '%'", con)-----------------------------------but if the above,DECLARE @pp1 varchar(10) SET @pp1='17' select * from emp_master where cast(emp_id as varchar(10)) like @pp1 + '%'", con)is working fine.So any better idea.......Thanks AgainParamu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-16 : 12:37:50
|
| where's kyprs declared? |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2009-03-17 : 03:02:01
|
| Variable kyprs is from FrontendParamu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-17 : 10:37:26
|
| what happened when you used first query?"select * from emp_master where cast(emp_id as varchar(10)) like " & kyprs & "'%'" |
 |
|
|
|
|
|