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 |
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2009-12-03 : 16:46:33
|
| Hi.I'd like to keep the first 6 digits of a feild.I've wrote:select SUBSTRING(product_oem, 1,len(product_oem)-6) as test from tbl_productand gives me this error:Invalid length parameter passed to the substring function.I think its because some of the values of my field are less than 12 digits.can u help me how can I say if the number of digits are 12 then select the first 6 digits? or any other way which says just pick the first 6 character with no errors.thanks in advanced |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-04 : 01:45:43
|
quote: Originally posted by X002548 ORSUBSTRING(product_oem+REPEAT(' ',6),1,6)Never mind...long dayDECLARE @y varchar(6)SELECT @y = '1234'SELECT SUBSTRING(@y,1,6) Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam
REPEAT?You forgot this is for SQL Server? MadhivananFailing to plan is Planning to fail |
 |
|
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2009-12-07 : 15:08:05
|
| thank u nso much for yr help |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|
|