Right 10 Digits From Column

Oct 7, 2014

Following function in not giving me correct output:

update dbo.raw
set PhnNumber = RIGHT(calling_pty,10)

What I want is....if in case column "calling_pty" i have values like 911111111111 so it should give me the output in column "PhnNumber" as 1111111111 means only right 10

View 3 Replies


ADVERTISEMENT

Removing Non-numeric Digits From Column

Jun 14, 2002

Using the following:

select hl, substring(hl,1,patindex('%/%',hl)) as test
from appointment

returns

hl test
A PCM/RODRIGUEZ A PCM/
Y OPTOMETRY/VISUAL FIELD TESTSY OPTOMETRY/
W DENTAL/DUNDON W DENTAL/
Y LAB
Y PCM/NEMES F/U Y PCM/
W NUTRITION/FIRM-A (ROOM E116)W NUTRITION/
W FIRM-A/SILVER/ABBOUD IIW FIRM-A/

I want to be able to remove the first 2 digits and the / to just have the clinic only remaining. Note that Y LAB is not listed in the test column..why? Any help is greatly apprecitated. Thank you....

View 4 Replies View Related

SQL 2012 :: Select Column Where Only 4 Digits In The Raw

Jun 25, 2015

How can I do this in TSQL, there are alot of wild chars but I could not find how to count them, in case below I only want id =1 and 2

this sql is not correct yet...

DECLARE
@a VARCHAR(22) = ' alpha1234 qwerew', @b VARCHAR(22) = '3456_Bravo', @c VARCHAR(22) = ' only_three123_Delta'
--SELECT 1 id, @a c UNION select 2 id, @b c UNION SELECT 3 id, @c c
SELECT * FROM
(SELECT 1 id, @a c UNION select 2 id, @b c UNION SELECT 3 id, @c c) b
WHERE c LIKE '%[1_3]%'

View 3 Replies View Related

Appending 2 Digits Infront Of A Column

Apr 17, 2008

I have a simple select statement. What I need is to append a 2 digit number infront of the relationship_type_id.


select distinct



customer_id,
acct_id,

parent_flag,

relationship_type_id

from customer_account sca


inner join account act


on sca.acct_id = act.account_number








the logic is that

If primary flag = 0 then 1st two digit of relationship_type_id = 10
else 1st two digit of relationship_type_id = 00

For Example:

Primary Flag Relationship_type_id After appending





Relationship_type_id


1 5 005
1 3 003
0 3 10
1 5 005
0 3 103



Can anyone help me with that?

Thanks

View 8 Replies View Related

Move Data Basedn On X Amt Of Digits In Column

Nov 8, 2005

I am looking for a solution to move all Part Numbers for a specific manufacturer that is 9 digits long to a new column.

Let me explain............

I have a product table that has three columns of product codes associated with that product (Part Number as PN, Series as Series, and Industry Code as ICDE). I now want to create a fourth column (Manufacturer Code as MCDE) as my database has grown for another product specific numerical designator that is specific for one manufacturer.

Currently I have the specific 9 digit codes in the same column as the Part Numbers, though they all have their specific rows (Part Numbers & Manufacturer Codes are not in the same cell).

Now the Part Numbers have various numbers, letters, and special characters, but the specific 9 digit manufacturer codes are pure numbers.

So my question is............

How does one go about moving these specific 9 digit codes to their new column and out of the Part Number column?

They will all be exactly 9 digits, no special characters, no letters, no spaces.

Is there a way to tell MS SQL to just move anything for that specific manufacturer that has the 9 digit manufacturer numbers to the new column, bypassing anything with letters, special characters or any part number that is not a pure 9 digit number?

View 2 Replies View Related

Reg Exp For Digits

Sep 18, 2005

Hi,This is not SQL Server database problem, however, net search has failedto generate a solution to the problem, I'm trying my luck at this NGnow.Problem, remove the special character, [ from text.e.g. text ="this is [1] and [stuff] and some [2] and hat [3] and dog"Desired result ="this is 1 and [stuff] and some 2 and hat 3 and dog"I know [[:digit:]] would find all the instances of digits insidebrackets such as [1], [2], [3]. However, I don't know how to get ridof the special characters of [ and ].Any regular expression expert out there?Thanks.Don

View 8 Replies View Related

I Need 2 Decimal Digits

Apr 14, 2008

Hello All,

Current Format :-
40.349.462.875.589.2100112127


Required Format
40.3049.4062.8075.5089.20100.00112.00127.00


Currently mine above row data type is float. i need two points after precisions.

Thanks

View 3 Replies View Related

Smallmoney With 2 Digits

Jan 2, 2008

I have a table for products and the price field is smallmoney data type. When I view the data stored it shows it with millionths. How do I get it to store only hundredths?

View 2 Replies View Related

Add Digits To The Front

Jul 20, 2005

Hi all,I have a number like so 778625 and want to make this a more meaningfuldate (UK) so how difficult is it to add two digits in this case 19 tothe front of this number?Many thanksSam*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 3 Replies View Related

Splitting Digits And Alphabets..

May 14, 2008

is there any builtin functions or any other ways to split digit and numbers in sql server2005.
   for example in  Patel1234 , i am want to split patel and 1234 seperately.
                                    thanks,

View 5 Replies View Related

Decimal Rounding To 2 Digits

Feb 16, 2012

This give me 6 digits to the right of the decimal point - can round it to 2???

CONVERT (decimal(18 , 2), 1.0 * NULLIF (vVotesR, 0) / NULLIF (vVotesR + vVotesD, 0) * 100)

View 3 Replies View Related

Find Value 9 Digits In Length

Apr 17, 2008

Just looking for some guidance on how to find a value thats 9 digits in length

View 2 Replies View Related

How To Find Records Containing Only Digits?

Mar 12, 2008

Hello,

I would like to find all the records that contain only digits. So far, I have this:


SELECT *
FROM tmp1
WHERE (word LIKE N'[0-9]')


It returns only ten results, each containing a single digit. What I need is to find all the records of any length containing only digits, like '378', '2005', etc. but not records containing both digits and other stuff (e.g. letters) like 'I95' or 'P2P'.

Any idea?

Cornelius

View 7 Replies View Related

Random Number-9 Digits Only

Mar 25, 2008

Hi,

I need to generate random numbers that will always contain 9 digits.
How can I do that?
Thanks

Whisky-my beloved dog who died suddenly on the 29/06/06-I miss u so much.

View 1 Replies View Related

Funny Characters And Repeating Digits

Jan 17, 2003

How do l filter out funny characters in a field like (',','@','#','"'.'/')etc And Repeating digits Like 5555555,2222,111111,00,
000000000.

Tried using the patindex but my method is too long.How do l do that ?

View 3 Replies View Related

Count Number Of Digits In Text

Jul 20, 2006

Hi guys,

I'm trying to write a producure to count the number of digits in a text.

i.e :
text
---------
12 fff 3 a.z
12345 ggg6gg a
123

Result:
--------
3
6
3

It seems to be real easy via RegEx in C# , but i cant figure it out in SQL.

Thank YOU!

View 11 Replies View Related

Adding The Cubes Of A Strring Of Digits

May 9, 2007

I need to take a numeric value and add together the cubes of each single digit. The string length may vary from row to row.

As as example the number 1234 has individual cube values of 1 (1 cubed), 8 (2 cubed), 27 (3 cubed) and 64 (4 cubed). The resulting sum of the cubes is then 1+8+27+64 = 100. The same result would occur for 1243.

The purpose is to look for numeric values in a table where the same digits occur in two different rows but in a different order.

How can I create a function to apply to a varchar column to produce my integer result ?

View 13 Replies View Related

Convert Time To Include 2 Digits

Mar 29, 2008

Hi,

I want to convert time 2:8:6 to 02:08:06 in the easiest possible way. How to do it without using Left() or Right()

thanks.

View 2 Replies View Related

Patindex To Find Special Character And Next 6 Digits

Dec 6, 2007

I am creating a view to pull data for a UPS integration I am doing. I currently have this view where I pull my data from. All is well accept for my PATINDEX,

Currently I have this PATINDEX So when a user puts this into delivery instructions "#999999" UPS_FINAL returns 999999 which is good for me to use. But The PATINDEX will also grab all kinds of neat stuff out of the delivery instructions field when I really only want whatever is after the # sign in the field.

I am new to sql and dont quite understand how this search is working but I think I am in need of a better way to search the field



Code:


WHEN SUBSTRING(P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions, PATINDEX('%[^a-z ]%', P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions) + 1, 6) IS NULL

THEN dbo.Address_Table.ups_code

ELSE SUBSTRING(P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions,
PATINDEX('%[^a-z ]%', P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions) + 1, 6) END AS UPS_FINAL


-------------------------------------------------------------------------------------
What I am looking to accomplish is a SUBSTRING that will search delivery_instructions



Code:


SELECT

TOP (100) PERCENT P21PLAY.dbo.p21_view_oe_pick_ticket.pick_ticket_no,
P21PLAY.dbo.p21_view_oe_hdr.order_no, P21PLAY.dbo.p21_view_oe_hdr.customer_id,
P21PLAY.dbo.p21_view_oe_hdr.ship2_name, P21PLAY.dbo.p21_view_oe_hdr.ship2_add1,
P21PLAY.dbo.p21_view_oe_hdr.ship2_add2,
P21PLAY.dbo.p21_view_oe_hdr.ship2_city,
P21PLAY.dbo.p21_view_oe_hdr.ship2_state,
P21PLAY.dbo.p21_view_oe_hdr.ship2_zip,
P21PLAY.dbo.p21_view_oe_hdr.po_no,
P21PLAY.dbo.p21_view_oe_pick_ticket.carrier_id AS Carrier,
P21PLAY.dbo.p21_view_oe_pick_ticket.carrier_id AS Supplier,

P21PLAY.dbo.p21_view_oe_hdr.cod_flag,
P21PLAY.dbo.p21_view_oe_hdr.terms,
P21PLAY.dbo.p21_view_oe_hdr.ship2_country,
P21PLAY.dbo.p21_view_oe_hdr.ship_to_phone,
P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions,
dbo.Address_Table.ups_code,

-----------Looks for special character and returns next 6 spaces as UPS_Shipper----------

SUBSTRING(P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions, PATINDEX('%[^a-z ]%',

P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions) + 1, 6)
AS UPS_Shipper,

------------------Checks view for email address or assigns alternate------------------
(CASE WHEN charindex('@', p21_view_contacts.email_address) > 0 THEN p21_view_contacts.email_address ELSE

'email@domain.com' END) AS alternate_address,

'Y' AS QVN, 'email@domain.com' AS failureaddress,

P21PLAY.dbo.p21_view_contacts.email_address,

------------When carrier_id is not one of these # then Null; else ------------------------------

CASE WHEN P21PLAY.dbo.p21_view_oe_pick_ticket.carrier_id NOT IN (105188, 105191, 105194, 105197, 105200,

105203, 105206, 105209, 105212) THEN NULL

----------------- Looks for special Character in delivery_instructions; if NULL then ups_code;
ELSE return value from delivery_instructions as UPS_Final--------------------

WHEN SUBSTRING(P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions,
PATINDEX('%[^a-z ]%', P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions) + 1, 6) IS NULL
THEN dbo.Address_Table.ups_code
ELSE SUBSTRING(P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions,
PATINDEX('%[^a-z ]%', P21PLAY.dbo.p21_view_oe_hdr.delivery_instructions) + 1, 6) END AS UPS_FINAL


FROM dbo.Address_Table INNER JOIN
P21PLAY.dbo.p21_view_oe_pick_ticket INNER JOIN
P21PLAY.dbo.p21_view_oe_hdr ON P21PLAY.dbo.p21_view_oe_pick_ticket.order_no =

P21PLAY.dbo.p21_view_oe_hdr.order_no ON
dbo.Address_Table.id = P21PLAY.dbo.p21_view_oe_hdr.customer_id LEFT OUTER JOIN
P21PLAY.dbo.p21_view_contacts ON P21PLAY.dbo.p21_view_oe_hdr.contact_id = P21PLAY.dbo.p21_view_contacts.id

WHERE
(P21PLAY.dbo.p21_view_oe_hdr.completed <> 'Y')
AND (P21PLAY.dbo.p21_view_oe_hdr.delete_flag <> 'Y')
AND (P21PLAY.dbo.p21_view_oe_hdr.will_call <> 'Y')
ORDER BY P21PLAY.dbo.p21_view_oe_pick_ticket.pick_ticket_no



Hope this makes since

View 4 Replies View Related

SQL 2012 :: Remove Digits From Fields Of Table

Apr 3, 2014

I have table like

name
22rajuvar
45 vamsgui
87 praveen
67kumar
32 vamshi

Above field mix with digits and character. I want to remove digits. I want o/p like ............

name
rajuvar
vamsgui
praveen
kumar
vamshi

View 8 Replies View Related

T-SQL (SS2K8) :: Arithmetic Formula To Stuff Digits

Apr 6, 2015

I have a column which needs to be 9 digits long. The first four digits are independent from the other digits. The following digits need to be 5 and I have to add leading zeros if they're less than 5. This is an awful design and I'd love to change it but I can't.

SELECT Cg.Fiid,
--Original Formula
SUBSTRING( CONVERT( varchar, Cg.Fiid ),1, 4 ) + RIGHT( '00000' + SUBSTRING( CONVERT(varchar, Cg.Fiid ), 5, 10 ), 5 ),
--My solution
STUFF(Cg.Fiid, 5, 0, REPLICATE('0', 9 - LEN(Cg.Fiid)))
FROM (VALUES(71927),
(498932),
(498934),
(38061278))Cg(Fiid)

View 9 Replies View Related

Wants To Increase Digits Of Numeric Data Type.

Sep 20, 2007



Hi! Every one,
I need to increase my numeric digit in a table.previous column name was "Amount",Precision=18 and scale=6, when I increase Precision=28 it show "Airthmatec Error",
even when increase precision in a new table it work properly.








Thanks.

View 1 Replies View Related

SQL Server 2008 :: Month Name And Year (2 Digits) Format

May 12, 2015

How to convert a date to the format as Month name and year(2 digits).

For e.g.- Jan 14, Feb 14......Mar 15

View 7 Replies View Related

Finding Code That Will Automatically Grab 3 Digits Before Dash?

Jan 6, 2014

I have the following table with two columns:

SEQ_NUM STATUS_CODE
101 D12
102 DWI - REGULAR DWW - EXPIRED
103 WRW - REG WRT - FUTURE

I would like to output the following:

SEQ_NUM STATUS_CODE
101 D12
102 DWI
102 DWW
103 WRW
103 WRT

The Status code column in the source table will have a single 3 DIGIT alphanumeric code, and sometimes a longer string. I need a code that will automatically grab the 3 digit code before the dash.

View 8 Replies View Related

How To Display Money Type Data With Commas Every 3 Digits?

Oct 4, 2006

How to display money type data with commas every 3 digits?

I tried :

CONVERT (money, ProjectCost, 1) AS ProjectCost

but it gives me the type as 1234.56 no commas in it?

can anyone help me with that?

thanks!

View 4 Replies View Related

SQL 2012 :: Populate Number With Leading Zeros To Make It As 5 Digits

Jan 23, 2015

Logic:ensure the Docket number is 5 digits and populate with leading zeros if not.I have to check input number field is 5 digits, if not I have to populate with leading zeros to make it as 5 digits.

View 2 Replies View Related

BUG: SSIS Imported Package Errors With 'Guid Should Contain 32 Digits With 4 Dashes'

Apr 10, 2006

I have imported a package using SSIS into the Maintenance Plan folder from another server.

It imports fine, but when i Modify the package then click save I get the following error : 'Guid should contain 32 digits with 4 dashes'.

This has been reported on other forums without resolution.



Pete



View 17 Replies View Related

I Want To Write An SQL Statement Which Returns Matching Values But Ignores The First 2 Digits Of The Search

Jan 26, 2007

I want to write a statement something like this
SELECT Add_Date, File_No FROM dbo.File_Storage WHERE (File_No = 11/11/1234/)
But i want the search to ignore the first 2 digits so that it will return e.g
10/11/1234, 09/11/1234  so that it's only matching the last part
Any Help Would be greatly appreciated Thanks

View 6 Replies View Related

Limit The Number Of Digits After Decimal Point In Flaot Data Type

Dec 12, 2007

Hi..
I have a column in the data base with the type Float,
I want to limit the number of digits after decimal point to 2 when I display the value in ASP.NET but I don't know how!?
the number that appear after calculation llike "93.333333"
I use decimal(2,2) as data type but an error accour and this is the message
"- Unable to modify table.  Arithmetic overflow error converting float to data type numeric.The statement has been terminated."
 Can you help me..
thanks
 

View 6 Replies View Related

Decimal Limited To 4 Digits To Right Of Decimal?

Jun 18, 2007





I need to store decimal values: decimal(20,15) in my SQL Server 2005 database.

I load data from flat file, convert it using Data Conversion Task to decimal(with scale: 15) and try to save it using OLE DB Destination.



It works fine for 4 digits after the decimal (like 1.1234), but always failes for more than 4 digits (1.12345).

Is the decimal limited to scale 4 ???



Thank you for your help!

Anna





View 3 Replies View Related

Integration Services :: Add New Column Based On Existing Column Using Derived Column Task?

Jul 28, 2015

I have a excel file which has a column called "Code" and their values are A,B,C,D,E,F,G,H.  I want to create a new column called "status" based on the values of "Code".

Code:

A
B
C
D
E
F
G
H

If A,C,E,G then "status" = "Active" else if  B,D,F,H then "Status" = "Inactive". I like to do it using "Derived Column".

View 4 Replies View Related

Transact SQL :: Calculate DateTime Column By Merging Values From Date Column And Only Time Part Of DateTime Column?

Aug 3, 2015

How can I calculate a DateTime column by merging values from a Date column and only the time part of a DateTime column?

View 5 Replies View Related

How To Refer A Column When The Referencing Column Is An Identity Column

Oct 16, 2006

Hi all,

The requirement is to have a table say 'child_table', with an Identity column to refer another column from a table say 'Parent_table'..

i cannot implement this constraint, it throws the error when i execute the below Alter query,

ALTER TABLE child_table ADD CONSTRAINT fk_1_ct FOREIGN KEY (child_id)
REFERENCES parent_table (parent_id) ON DELETE CASCADE

the error thrown is :
Failed to execute alter table query: 'ALTER TABLE child_table ADD CONSTRAINT
fk_1_ct FOREIGN KEY (child_id) REFERENCES parent_table (parent_id) ON DELETE
CASCADE '. Message: java.sql.SQLException: Cascading foreign key 'fk_1_ct' cannot be
created where the referencing column 'child_table.child_id' is an identity column.

any workarounds for this ?

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved