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 |
|
h2sut
Starting Member
40 Posts |
Posted - 2008-05-06 : 17:54:28
|
| Hello i wrote this case statement to choose the password for a certain user but seems not to work. I have to get custom1 from another table. select cast(custom1 as varchar(5)) from dbo.newhiresraw where id =userid) when custom1 'C%' then password = abcd4321 when not 'C%' then password = [postalcode] end [postalcode].Not sure if custom1 = C then password =abcd4321If custom1 not = C then it will be a zipcode.not sure on the syntax any suggestions |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2008-05-06 : 18:44:01
|
| Can you post both the table structure and the result expected?ThanksKarunakaran |
 |
|
|
h2sut
Starting Member
40 Posts |
Posted - 2008-05-06 : 20:11:35
|
| Newhire: userid,lastname,firstname,custom1Temp: has all the above but custom1So I use the select cast(custom1 as varchar(5)) from dbo.newhiresraw where id =userid) to be able to get the custom1 field in temp. In custom1 has characters.IF char is =C then password whould be abcd4321. If password is not C then it should be there zipcode. |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2008-05-06 : 22:51:10
|
But your table structure does not have zipcode column. Where does this comes from?Your temp table structure also does not have custom1 column, so what do you mean by this?quote: I use the select cast(custom1 as varchar(5)) from dbo.newhiresraw where id =userid) to be able to get the custom1 field in temp
ThanksKarunakaran |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-07 : 00:33:35
|
quote: Originally posted by h2sut Hello i wrote this case statement to choose the password for a certain user but seems not to work. I have to get custom1 from another table. select cast(custom1 as varchar(5)) from dbo.newhiresraw where id =userid) when custom1 'C%' then password = abcd4321 when not 'C%' then password = [postalcode] end [postalcode].Not sure if custom1 = C then password =abcd4321If custom1 not = C then it will be a zipcode.not sure on the syntax any suggestions
Post your table structures with some sample data and o/p you expect. |
 |
|
|
|
|
|