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


ADVERTISEMENT

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 View Related

Move Data From One Column To Another In Same Table

Sep 12, 2004

Okay, after I got everything imported, I found that a few thousand columns had "Shifted" on me. So now I am trying to "Shift them over" to where they need to be.

I did this:
INSERT INTO dbo.TABLENAME (COLUMN_NAME_TO_BE POPULATED)
SELECT COLUM_NAME_OF_INFO_TO_BE_MOVED
FROM dbo.TABLENAME
WHERE MFG = 'MANUFACTURER_NAME' AND PN LIKE '8888888888'
GO

I populated the PN column with 8888888888 to use as a reference point, and the MFG column already was populated with the correct name, so I was using those as my unique reference points.

Other columns that have the same MFG name are correct, so I have to use two unique identifiers to specify the actual data that needs to be moved.

It inserted 'NULL' in the whole table after I ran it in the Query Analyzer. It appeared to disregard the WHERE statement all together
Any ideas on what I am doing wrong here?

Is there a way to move the data from one column to the next one over by specifying other WHERE criterias?

View 1 Replies View Related

Move Column Of Data To Another Table With A Join

Oct 12, 2013

I have two tables. They both have an identity field to join them together. One of the tables has a column of data that I want to put in the other table. I need to make sure the data is brought over using the join so it updates that column for the right record.

I am struggling with this. Should I use a update or an insert? I'm leaning toward update but I can't figure out how with the join.

This is what I have tried so far:

Update grpcon.GroupID = groups.GroupID
from grpcon Inner Join groups
on grpcon.GroupNum=groups.GroupNum

View 1 Replies View Related

Move Data From One Column To Another Column And Row

Aug 7, 2006

need some help converting a table which has one row for each year. Displaying the data so the each row will contain all of the information for the title and all of the years displayed in separate columns.

I have a SQL Querry which returns the data looking like this (the querry is grouping by Title and by year, then adding up the quantity of rows):

Basic Information needed for Life Insurance 25 2005
Basic Information needed for Life Insurance 45 2006
Ea Chairmans Conference 10 2005
EA Chairmans Conference Press Release 33 2005
EA Chairmans Conference Press Release 21 2006
EA Chairmans Inner Circle Press Release 16 2005
EA Chairmans Inner Circle Press Release 46 2006
EA Honor Ring Press Release 13 2005
EA Honor Ring Press Release 35 2006
EA National Conference Press Release 6 2005
EA National Conference Press Release 9 2006

I need this data displayed like this:

Title 2005 2006
Basic Information needed for Life Insurance 25 45
Ea Chairmans Conference 10 10
EA Chairmans Conference Press Release 33 21
EA Chairmans Inner Circle Press Release 16 46
EA Honor Ring Press Release 13 35
EA National Conference Press Release 6 9


What I want to do is to basically say:

If Row 1 Title = Row 2 Title and Row 1 Year = Row 2 (Year + 1)) Then

add to grid Row 1 Title, Row 1 Qty, Row 2 Qty

Skip Row 2 and go to Row 3 (repeat this step until end of data)

End

Is there any way in the SQL querry to retrieve this data in this format so that I can display it in a datagrid?

Is there any way to display the data in this pattern.

Below is the code I am using now, but since the moving of the data is done in code it is very slow.
****************** Global Variables

Dim dbName As String = "Region_Web_Page_Hits"
Dim ColumnCount As Integer




Function ReturnColumnHeaderAndHitsDataSet() As System.Data.DataSet
'******** This will bring back the column Headers and Gross Hits per Column
Dim ColumnHeaderAndHitsQueryString As String = "SELECT DISTINCT TOP 100 PERCENT " & _
"YEAR(dat_Date) AS str_Year, COUNT(str_PageName) AS int_YearHits " & _
"FROM dbo.tbl_web_page_hits " & _
"WHERE (str_URL LIKE N'%press_Release%') " & _
"GROUP BY YEAR(dat_Date) " & _
"HAVING (Not (Year(dat_Date) Is NULL)) " & _
"ORDER BY YEAR(dat_Date)"

Dim ColumnHeaderAndHitsDataSet = LoadDataArray(ColumnHeaderAndHitsQueryString, dbName)
Return ColumnHeaderAndHitsDataSet
End Function


Function ReturnTableDataSet() As System.Data.DataSet
'This query string will return the data needed to display the report.
Dim TableQueryString As String = "SELECT TOP 100 PERCENT " & _
"str_PageName, COUNT (str_PageName) AS int_Hits, YEAR(dat_Date) AS str_Year " & _
"FROM dbo.tbl_web_page_hits WHERE str_URL LIKE '%Press_Release%' " & _
"GROUP BY str_PageName, YEAR(dat_Date) ORDER BY str_PageName"
Dim TableDataSet = LoadDataArray(TableQueryString, dbName)
ColumnCount = TableDataSet.Tables(0).Columns.Count
Return TableDataSet
End Function

'******* Function to Load the Data Array
Function LoadDataArray(ByVal queryString, ByVal dbName) As System.Data.DataSet
Dim ConnectionString As String = ConnectionStr(dbName)
Dim sqlConnection As SqlConnection = New SqlConnection(ConnectionString)
Dim sqlCommand As SqlCommand = New SqlCommand(queryString, sqlConnection)
Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand)
Dim dataSet As DataSet = New DataSet
dataAdapter.Fill(dataSet)
sqlConnection.Close()
Return dataSet
End Function



Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

If Not Page.IsPostBack Then
Dim Sort_Field As String = ""
dg_Data.DataSource = QueryMethod(Sort_Field)
dg_Data.DataBind()
End If
End Sub

Currently I have a bunch of Classic ASP code which puts the data in to an array and then into a table with a series of if statments, but it is really slow.

I want to bind it to a data grid and if possible let the SQL statement format the data for me.

View 1 Replies View Related

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

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

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

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

How To Move From One Column To Another Using Sql Query With Asp Programming

Aug 29, 2006

I have a table A I have Five columns and Each consist of Five rows of textcolumn 1column 2column 3column 4column 5Thru Sql coding i want to move from one column to another column - When Date Changes I need ASp and sql code for this Or ATleast i need sql query for how to move one column to another

View 1 Replies View Related

Can I Move Some Column Position By Using SQL Command ?

Jun 1, 2007

I created SQL table follow by XSD fileAnd when any users added new column to XSD in ordinal position = 3 But after my program successfully created new column, its position is the last position  What can I do ???? I suspect  why I can't set it (I've looked for solution on MSDN already)even though We can see ordinal position bythis query  SELECT *FROM INFORMATION_SCHEMA.Columns   What can I do for solving ???? Help me please 

View 1 Replies View Related

Delete/Move Certain Info From Column - Leave The Rest?

Nov 10, 2005

I have a column that contains extra info that needs to be moved to another column or deleted alltogether. is there a way to select these items and move them to another column, leaving the rest of the data in the original column?

EXAMPLE

MYTABLE >COLUMN1
May have Data Like: ABCDE123 SER1 or XYZ12DEFSer1:1

WHAT I NEED TO DO IS
Move anything after the SER1 to a new column and retain the rest of the data in the original column. making it look something like this:

COL1 COL2
ABCDE123 SER1
XYZ12DEF Ser1:1

Another question is if there is a way to delete extra spaces? Like make all data that has two or more extra spaces, just single spaces and any additional spacing after a row of data, delete all additional spaces after the last letter/character/number.

One more question - What would be a great resource to learn MS SQL in more depth?

I am trying to learn ASP/VBScript/JavaScript/ and now MS SQL all at once b/c this is what my business depends on. Trying to be 5,000 hats at once can get confusing and overwhelming, so I am looking for any "Crash course" I can to learn as much, as fast as possible. Any direction or ideas?

Thank you.

View 4 Replies View Related

Reporting Services :: Print Data With Blank Space And Move To Continue Data To Next Page

May 15, 2015

I am using SQL Server report 2008/2012 (SSRS) and my report viewer contains body content with 3 Row groups.
While printing the report,  data print with blank space and move to continue data to next page. 

Departure flight : 70 rows
First Page            : 42 rows printed
Second Page      : 23  rows printed  [ Supposed to be print 28 ,  if the total count of records more than 23 and less than 42 then the page print only 23 records ]
Third Page           : 5 rows printed

Departure flight : 42  rows
First Page            : 42  rows printed [Report max. record allowed to print 42 rows so if total record is 42 then print perfectly ]

Departure flight : 26 rows
First Page            : 23 rows printed [Supposed to be print 26, if the total count of records more than 23 and less than 42 then the page print only 23 records ]
Second Page      : 3 rows printed

View 3 Replies View Related

Move Text Data (not A File) Into An Image Data Type

Mar 11, 2008



The ERP manufacturer used an image data type to store large text data fields. I am trying to move these data types from one database to another database using either Sql Queries or MS Access. I can cast them as an 8000 char varchar to read them directly but have no luck importing into these image data fields.

Access and Crystal are not able to read these fields directly.

Any suggestions? Most information about these fields has to do with loading files but I am just moving data.

Thanks,

Ray

View 1 Replies View Related

Does SQL Server Move Records Between Partitions When Updating The Partition Key Column?

Apr 4, 2007

If I run an UPDATE query on a table which is partitioned by the column I am updating - will the records be moved to another partition?



ie. I have a table where Historical bit column marks whether a particular record should go to Partition1 (=0) or Partition2 (=1). Now, I update a record in that table and change the Historical column value from 0 to 1. What happens with that record?

View 3 Replies View Related

Move Data To New SAN

Jun 14, 2006

Next month client is moving servers to new location. The servers will get new ip and subnet Our user db's which are on a SAN will be moving to new SAN. My plan is the following, please correct any mistakes.

1. Do full backups of everything
2. Detach user db's
3. Copy these files to usb box (100 gig worth)
4. After server is in new world bring it up
5. Copy db files from usb
6. Attach db files

View 6 Replies View Related

Best Way To Move Data

Jun 7, 2007

Hi,

I'm a C# developer, not a DBA, but fairly familiar with sql server 2000 and learning 2005. I have a need to update a table on one sql server from another remote sql 2005 server. Both will be SQL 2005, but will not be on the same network, so there will be firewall issues to contend with. Security is not a huge concern as the data is public info and not personal secure information or anything like that. What I'll have is a table of data in one sql database. I will have a copy of that data on another sql server that is used at an ISP and drives a web site. I need the table at the ISP sql server to get updated from the SQL server that is onsite in our office on our private network. I would like to not have to get network admins to open sql server ports if possible, so I guess I'm wondering if there is an easy way with SQL 2005 to update data from one sql server to another in the environment that I have described that maybe could expose the data over a common port (ie port 80). I don't want to have to use integrated security as I'm not sure this would work between remote databases in this scenario. I don't know if the web service end point support in sql 2005 would allow this. The examples I have seen online show a sql endpoint created and then accessed from a .NET application. I can do that if I have to, but I would rather do all of this inside the database in some fashion. I am open to any idea that would work and if I need to, I can ditch the idea of using something over port 80 and can get the necessary ports open between the sql servers. This is a pretty simple scenario that we have with one table of data needing to be updated weekly on a web based sql server from a remote sql server.

Any ideas on how you would approach this would be greatly appreciated. Security for the data I'm accessing is not a huge concern as the data is public domain as I've said, but I need to make sure the rest of the server and database on both ends are secured.

Thanks for any help!

View 6 Replies View Related

What Is The Best Way To Move Data From...

Jul 20, 2005

Am MS Access 2000 DB To an SQL SERVER 2000?(without Enterprise manager)

View 3 Replies View Related

Move Data Between Databases

May 18, 2008

hi, I currently uses SQL Server 2005.I need to move the data to my website, how do I do that? I have the SQL Server Management Studio Express but I couldn't not get it to export the data in .sql file (which is needed to import to my website's SQL database).Please let me know of any tools I need to perform the task. thanks. 

View 3 Replies View Related

Move Data Between Database

May 15, 2006

Currently we update database A everyday with tables from database B.
Database is India and has poor connection speed. What would be the best method of moving this data.
Currently it's about 100 tables and on average its about 900 mb.
Any input is greatly appreciated.
thanks,

View 3 Replies View Related

How To Move Data Fast

Jan 23, 2004

Hello everybody
We need to move table T1 from database A to T1 database B on same server

size of table T1 15 GB and 40000000 rows

database B just created and will act as warehouse

could it be done simply by
1.creating table T1 on db B and then
2.set db to simple recovery
3.
insert into B.dbo.T1
select * from A.dbo.T1
4. create all the indexes on table T1 in db B

free disk space is 35GB

Any idea how to optimze import
Thank you

View 5 Replies View Related

Move All, But Data, From One Sql Server To Another

Feb 23, 2007

Guys,

We are currently moving our environment. I was told that we need to copy all the stuff over. More specifically, we want to move everything except the data, as our data is dynamic and will fill up in a few days by itself.

What is the best way to move everything over from one server instance to another?

My current approach is the following:

1. Create the file groups we have on our current server on the new server
2. Script out all databases with stored procedures, functions, views, priviliges, indexes ...
3. Script out all the jobs
4. Script out all the dts packages (or rather save each in a file)
5. Load all scripts into the new sql server
6. Re-create user accounts (can these be scripted out also and then loaded?)


Am I missing something or is there a wiser alternative?

Thanks a lot

View 3 Replies View Related

Move SQL 2000 Data To SQL 7

Mar 12, 2004

We have a problem with our SQL 2000 server which we know is a product bug.

Is there anyway of importing, Copying the sql 2000 table back down to SQL 7 until the issue is resolved,

many thanks

View 1 Replies View Related

How To Move Data Files

Jul 20, 2005

hello,my problem is how to move data files drom drive c: to drive d: ??--MarcinS

View 1 Replies View Related

Move Data From Sybase

Apr 23, 2008

I need to move data from Sybase ASE to SQL Server 2005. What is the best way fo doing it?

View 1 Replies View Related

Move Data From One Database To Another

Nov 12, 2007

I have two databases DB_1 and DB_2 on my server. Both of them have 25 identical tables.

Tables under DB_2 gets refreshed with new data daily and once it's ready with new data, those data should be copied to DB_1 tables (deleting any existing data and loading it with new data).

My question is there any other way other than using Import Data Wizard for moving the data between two databases which included deleting any existing data on DB_1 tables and loadit with new data.

Please let me know...Thanx in advance...

View 7 Replies View Related

How Can I Move My Production Data Only To My Dev Env.

Sep 14, 2007

I'd like to move data from my prod. env. to my dev. env. The data in dev would be replaced by the prod one. I cannot do a detach/attach or backup and restore due to some already existing dev objects located in the dev. env.

Any lead on how I can do this?

Thanks Marcel

View 5 Replies View Related

How Do I Move Data From One Database To Another?

May 8, 2007

I have two databases located on the same server. I was able to script a identical table in the other database, but how do I transfer the table data there?

View 5 Replies View Related

How Do You Move Data From One Table To Another?

Apr 2, 2008

I don't know what to do here please help! I have 2 tables here and I want to move selected data in one table to another but im not sure how to do it.

Thanks in advance =)

View 4 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

Move Data From SqlDataSource To A TextBox

Apr 9, 2007

I have a DataReader on a web page: <asp:SqlDataSource ID="ChangeInfoRecord" runat="server" ConnectionString..........
I want to display the value of one of the returned field in a text box.  What is the correct syntax?  I tried
RolledFromDisplay.Text = ChangeInfoRecord("RolledFrom")
but that isn't it.

View 1 Replies View Related







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