Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Split A Column Into 2 Columns


Hi everyone
I guess this should be a simple question for the gurus
I have a Data in a column which is to be places in 2 columns instead of
one. How do i go about doing it in MS SQL server? Could someone please
help me. I could do it in access with an update query but things are a
little different in SQL server so I am a little lost.

Eg.
Name
John?Doe
to be split into
Name LastName
John Doe

Thanks in advance.
Prit




View Complete Forum Thread with Replies

Related Forum Messages:
Split One Column Into Multiple Columns
Hi all,
I have a requirement like this  ,
I have Address Column.It is containing data like Mr. K KK Tank Guntur Jal Bhavan, Univercity Road, Rajkot 9843563469
I have to split this into 3 more columns like(Address1,name,phoneno)--
Means i have 4 columns including Address Column.(Address,Address1,name,phoneno)
 
Example:
Address:Rajkot
Address1:Univercity Road
Name:Mr. K KK Tank Guntur Jal Bhavan
PhoneNO:9843563469
 
How can i acheive this one with out data lose in Address Column.
Thanks in advance.
 
 
 

View Replies !
Query Split Column In 2 Columns In SQL
I like to push 1 column into 2 different columns just to show it on the screen. So no import in another table ore something like that.
I have a table like this:
Select Name from Cars;
Result:
Col1
BMWMercedesFordAudi
But i like to make a query so it is displayed like this:
Col1                Col2
BMW               FordMercedes         Audi
So i can bound a table directly to that column!Is this possible with SQL, and how can i build it.Thanks.

View Replies !
Split A Single Column Data In To 2 Columns
Hi
This is probably a very basic question for most people in this group.
How do i split the data in a column in to 2 columns? This can be done in access with an update query but in MS SQL server I am not sure.
Here is an example of what i want to acheive

FName
John?Doe

FName LName
John Doe

thanks for the help
prit

View Replies !
Split Address Value Into Two Columns
I am trying to get an address field into 2 colums.  I need the number value in one column and street name in another column.
 
The data is stored:
876 blue ct
9987 red dr
23 windyknoll
 
This is what I haveelect
substring(Address,0,charindex('',Address)) as number
,substring(Address, (charindex('',Address)+1)
,len(Address)) as address
from contact
 
 

View Replies !
Split The String Into Columns
 

 
I have a table called products with the values like
 
ProductId  ProductName
10            A
20           D,E,F,G
30           B,C
40           H,I,J
 
I need to display each productid's with
 
ProductId  ProductName
10           A

20           D
20           E
20           F
20           G
30           B
30          C
40          H
40          I
40          J
 
I will be appreciated if you can send me the code.
 
Thanks,
Mears
 
 

View Replies !
Split The Data Into Columns
I have a table called products with the values like
 
ProductId  ProductName
10            A
20           D,E,F,G
30           B,C
40           H,I,J
 
I need to display each productid's with
 
ProductId  ProductName
10           A

20           D
20           E
20           F
20           G
30           B
30          C
40          H
40          I
40          J
 
I will be appreciated if you can send me the code.
 
Thanks,
Mears
 

View Replies !
Split Row's Columns Across Multiple Tables
Hello,

Hoping someone here can help. Perhaps I'm missing something obvious, but I'm surprised not to see a data flow task in SSIS for splitting *columns* to different destinations. I see the Conditional Split task can be used to route a *row* one way or another, but what about columns of a single row?

As a simple and somewhat contrived example, let's say I have a row with twelve fields and I'm importing the row into a normalized data structure. There are three target tables with a 1-to-1 relationship (that is, logically they are one table, but physically they are three tables, with one of them considered the "primary" table), and the twelve input fields can be mapped to four columns in each of the three tables.

How do I "split" the columns? The best way I can see is to Multicast the row to three different OLE-DB Destinations, each of which inserts to one of the three target tables, only grabbing the four fields needed from the input row.

Or should I feed the row through three successive OLE-DB Command tasks, each one inserting into the appropriate table? This would offer the advantage, theoretically, of allowing me to grab the identity-based surrogate primary key from the first of the three inserts in order to enable the two subsequent inserts.

Thoughts?

Thanks in advance,
Dan

View Replies !
How To Split Columns Into Multiple Rows
SOURCE TABLE
ID DESCRIPTION
1 I am a programmer
2 I am a doctor

Destination Table

ID LINE DESCRIPTION(Varchar10)
1 1 I am a pro
1 2 grammer
2 1 i am a doc
2 2 tor


Please someone help me on this.

View Replies !
Break /split From A Cell Into Columns
hi,

i have labels for data stored in one cell
eg: item1; item22; item231;
and i want to convert it in following output
(probably using substring and charindex)

No_question| item_position | label
1|1| item1
1|2| item22
1|3| item231

any idea?

View Replies !
MS Access Detail Split Into Columns On Report
I would appreciate any help on this project. I have created an Access database that contains one vehicle. I have also included all options on that vehicle, which are in one column. Therefore the main criteria for the vehicle is listed each time for each different option. On my report I am grouping by the vin and placing the main criteria in the group header area of the report. The options are going into the detail section. How do I get the options to print in two columns within the detail section? I am unable to find any help on this subject, so I am asking you for help.

Thank you all! Timpy

View Replies !
Split Comma Separated Values Into Columns
 

Hi,
 I have data like this in my table:
 
AppId   Gender
1         x
2         y

3         x, y
4         x, y, z
 
I need to transform like this:
AppID          Gender
1                  x
2                  y
3                  x
3                  y
4                  x
4                  y
4                  z
 
How to do this?
 
Thanks in advance

View Replies !
Split A Column
Hi everybody

Does any body know how to split a field in a table into two fields

eg
usermaster(table)
userid(field)

usermaster has 40 users with user id 1 to 40
i want to get data as

userid userid
1 21
2 22
3 23
. .
. .
. .
20 40

Thanks you very much

View Replies !
How To Split Datetime Column
I have column that hold datetime , i want to split the column into many columns ex:
column --> 01/01/2007 00:00:00
i want tp split to day month year hour minute second

View Replies !
How To Split Three-value Column Into The Same Target?
Hi everyone,

We've got a source file which owns three different values: 'A','B','M'.

Where 'A' stands for "New Rows" and 'B' for "Delete rows" and 'M' for 'Update rows'

Using Conditional Split task we can redirect each subset into a OLEDB Destination but we are wondering how can we do the same using only one OLEDB? We've got only one table.

Thanks for your input and time,

 

 

View Replies !
Split Values From Within Column
 
I have been trying to separate firstname,last name,middle from name column
 
Existing Format
Column Name =FIRST,LAST M
 
Desired
First
Last
M
 
I would llike to divide one column into three columns...How can i achieve it..
 
Please let me know
 

View Replies !
Split Column Into Severl Ones
Hello,

I have a table which contains a column like that:

Comment
-----------------------------------------------------------------------
User: Toto Password: Toto-Toto


I'd like to have in the same table:

Comment                                          User             Password
--------------------------------------------------------------------------------------------------------
User: Toto Password: Toto-Toto          Toto              Toto-Toto

Do you have an idea of how to do it in SSIS?
Thanks a lot for your help.

View Replies !
How To Split A Database Column ?
 

Hi,
 
I have a column, for example Prod_ID count is 100 (contains Raw Matl & Finished Matl).
 
I want to split this 2 columns as
 
Raw Matl               Finished Matl
60                          40
 
Can anyone please help me how to do this in SQL Server.
 
Thanks in Advance
Rajesh

View Replies !
Split Data In Column
hai all,
This is my first question to this forum.
here is my situtation:
I am into report testing I need to test a report for which i have write a query,iam using qery analyser for runing query


Database : sql server
tabel name :job_allocations
column naME :technicain code

Based on techincain code in joballocation tablei need to get technician cost from other table for the particular technician.

Based on the technician code user chooses column will be updated
if single data will be TC01
if more than one then data will be TC01:TC02:TC03

user can choose any number of techincian for a job

MY problem is :How to split tha when there is multiple technician and calculate cost for the job
Ineed it in single excecution query

Table structure

job_allocation table

jobcardn_fk Technician_code
jc01 TC01
jc02 Tco1:Tco2:Tc03......


I need it in



jobcardno_fk TEchnician_code
jco1 Tc01
jco2 Tc01
jco2 TC02
jc02 Tc03




TKs ands Regards
Diwakar.R

View Replies !
Split Data Into Two Column Table
Hello all,

Little layout question. Assume my dataset returns the following data:

A

B

C

D

E

 

How can I present this data in a table (or list, or matrix) splitted into two columns:

A     B

C     D

E     

 

Any idea will be very appreciated! Thanks a lot!

TG

View Replies !
Query To Split A Database Column ?
 

How can i write a query to split a database column and shows 2 new columns.  In my database column
I have 2 mixing items and need to split out to 2 columns.  Normally I have to write a query and change parameter
and run another query. 
For example a database column with average number and range number. 
Thanks
Daniel
 

View Replies !
How Do I Split A Column Result By A Nonalphanumeric Character?
I have a column that returns client numbers.
The client numbers are 4-6 characters in length.  A period (.) is added to the end of the client number, and then one last digit (1-4) is affixed at the end to denote a categorization.
In SQL, I need to figure out how to divide these results into two columns, one for the client number and one for the categorization number.
EG:  client #4334.1 would become 4334 for client # and 1 for categorization number
or
         Client #424561.3 would become 424561 for Client # and 3 for categorization number.
I have to strip out the period in the process and leave myself with just the numeric characters divided into two columns.
Ive been researching my brains out on string queries and substring queries and I can't figure out how to parse out the period and/or to have SQL understand that I need everything BEFORE the period for one column and everything AFTER the period for the second.
Is it possible to do this?  I really need help on this one.
Thank you :)

View Replies !
Comparing A Column List Split To A Table.
Let me see if I can explain my situation clearly.I have a table with the columns:answer_id, question_id, member_id, answer- answer_id is the primary key for the table.- question_id relates to another table with questions for a user. Thetable holds the question and the possible choices in a varchar fieldseparated by a delimiter.- member_id is self-explanatory- answer is a varchar field of all the choices the user selected,separated by a delimiter.Here is my problem.I am trying to search all members that have answered, say, question_id= 2 where they selected 'brown' as one of their choices.i can do this if they selected ONLY that item, but not multiple items.The problem is this portionanswer in(select valu from dbo.iter_intlist.....I need this to be something like....function_to_return_all_separated_answers(answer) in(select valu from dbo.iter_intlistThe current way, it is only returning members that have an answer'Brown', not 'Brown, Blue' in their answer field. Make any sense? So,what I need to do is separate the list of answers and say :select member_id from profile_answers whereANY ANSWER in function_to_split(answer) MATCHES ANY OF THESE (selectvalu from dbo.iter_intlist...It seems I might have to join or something, I am just a little lostright now.Here is my proc.ALTER procedure search_detailed_get_ids@question_id as integer,@answers as varchar(8000),@member_ids ntextasdeclare @v as varchar(8000)--get the delimited string of all possible answersset @v = (select bind_data from profiles_questions where question_id =@question_id)--prepare it for the function only accepting 1 charset @v = replace(@v, '||', '|')--gimme all members that matchselect member_id from profiles_answers where question_id = @question_idand answer in(select valu from dbo.iter_intlist_to_table(@v, '|') where listpos in(select valu from dbo.iter_intlist_to_table(@answers, ',')))and member_id in (select valu from dbo.iter_intlist_to_table(@member_ids, ','))returngo

View Replies !
Split Column Data Into Multiple Lines
 

Hi,
    I have a scenario, where I have a string column from database with value as "FTW*Christopher,Lawson|FTW*Bradley,James". In my report, I need to split this column at each " | " symbol and place each substring one below the other in one row of a report as shown below .

 "FTW*Christopher,Lawson
  FTW*Bradley,James"

 
Please let me know how can I acheive this?

View Replies !
How To Split A Delimited Column Into Mulitple Rows In The Dataflow?
I'm sure there is probably a very easy solution that I am just not seeing or can't Google...

I have a DataFlow that includes a column of Delimited values (i.e. Value1,Value2,etc..). As this DataFlow is populating a parent table, I need split the values into their own dataflow and populate a child table. I've tried a script transformation and couldn't figure out how to accept 1 delimited input row and output multiple rows after a split. Any ideas?

TIA,
Matthew

View Replies !
How Can I Split Fields And Depending One Column Decide The Foreing Key
I´m wondering how to solve the following scenario with SSIS

I have a CITY table and a STATE table, I have to load a file with the information regarding to the CITY:

 
the state table is like this:

 
StateCode(PK)      stateLegalCode         stateName
=============  ==============   =========
1                          01                            Florida

 
the city table is like this:

 
citycode(PK)         cityLegalCode          cityname          StateCode(FK)
============    =============        ========        =============
1                          1001                           Quakertown       1

 
the file has the following information
 

cityLegalCode            cityName
=============       ========
01-1001                     Quakertown
...

how can I load the file into CITY table:

1-)  with the file's cityLegalCode I have to split the string and if the two initial digits are 01 the registry must have 1 in the StateCode(FK).

how can I do something like that using SSIS???

thanks

View Replies !
Need To Find An Easy Way To Split A Column In Table Without Using Cursor Or Temp Tables
Hi ,
I have two tables within a SQL database. The 1st table has an identified column and column which lists one of more email identifers for a second table,
e.g.
ID     Email
--     ----------
1      AS1 AS11
2      AS2 AS3 AS4 AS5
3      AS6 AS7

The second table has a column which has an email identifier and another column which lists one email address for that particular identifier, e.g.
ID      EmailAddress
---     ------------------
AS1      abcstu@emc.com
AS2      abcstu2@emc.com
AS3      abcstu3@emc.com
AS4      abcstu4@em.com
AS5      abcstu5@emc.com
AS6      abcstu6@emc.com
AS7      abcstu7@emc.com
AS11     abcstu8@emc.com
I need to create a stored procedure or function that:
1. Selects an Email from the first table, based on a valid ID,
2. Splits the Email field of the first table (using the space separator) so that there is an array of Emails and then,
3. Selects the relevant EmailAddress value from the second table, based on a valid Email stored in the array
Is there any way that this can be done directly within SQL Server using a stored procedure/function without having to use cursors?

Many Thanks,
probetatester@yahoo.com

View Replies !
How Can I Set Constant Padding Between The Columns Of The Column Chart(stacked Column Sub-type)?
Hi All,

I am working on a column chart type (stacked column sub-type) report.

Our customer requires us that the space(padding) between the columns should be a constant(including the space between the Y-axis and the first column). I know how to set the width of the columns, but I really don't know how to set the width of the space between them. The columns just varies the space between them automatically according to the number of the columns (the number of the columns is not certain).

Thanks a lot in advance!

Danny

 

 

 

View Replies !
Trying To Split My Columns Into Years (col1 Must Have Vals For 2005, Col2 Vals For 2006)
Hi, i'm reasonably new to reporting services and am looking for a way to split my reports' Years to compare the months in year 2005 to 2006 but i can't get my data nest to one another in a single line, it splits the years into different rows

as an example this is what i want if you can decipher that
















2005
2006
Growth
2005 Year to Date
2006 Year to Date
Year to Date Growth




turnover
gross profit
turnover
gross profit
turnover
gross profit
turnover
gross profit










Jan
250500
75300
280200
84100
11.85629
11.686587
250500
75300










Feb
205000
67950
190350
59900
-7.14634
-11.84695
455500
143250
take the month above and add the
current months values


Mar
217670
70540
234200
78000
7.594064
10.57556
673170
213790










Apr
270780
84000
290400
93000
7.245735
10.714286
943950
297790










May
265000
79260
289050
90200
9.075472
13.802675
1208950
377050










Jun
277300
81050
277900
82000
0.216372
1.172116
1486250
458100










Jul


























Aug


























Sep


























Oct


























Nov


























Dec



























Here is my Query:

SELECT /*DT.[YEAR],*DT.[MONTH],*DT.MONTH_NAME,*/ DC.CLIENT_KEY, (select SUM(FT.Cost)where dt.[year] = 2005) AS COST , (select SUM(FT.Price)where dt.[year] = 2005)AS SALES,(select SUM(FT.Cost) where dt.[year] = 2006),(select SUM(FT.Price) where dt.[year] = 2006)--, SUM(FT.QTY) AS QUANTITY, SUM(FT.PRICE) - SUM(FT.COST) AS GP,(SUM(FT.PRICE) - SUM(FT.COST)) / SUM(FT.PRICE) * 100 AS GP_PERCENTAGEFROM FACT_TRANSACTION FT, DIM_TIME DT, DIM_CLIENT DC, DIM_INVOICE_TYPE DIT, DIM_PRODUCT DPWHERE FT.TIME_KEY = DT.TIME_KEYAND FT.PRODUCT_KEY = DP.PRODUCT_KEYAND FT.CLIENT_KEY = DC.CLIENT_KEYAND FT.TYPE_KEY = DIT.TYPE_KEY AND DIT.TYPE_KEY NOT IN (5,6,13,14,15,16,17)AND DC.CLIENT_SERIALNO = '86634'--AND DT.[YEAR] IN(2005,2006)AND DT.[MONTH] IN(1,2,3,4,5,6,7,8,9,10,11,12)AND DP.PRODUCT_KEY <> 1668684GROUP BY DT.[YEAR],DC.CLIENT_KEY--, DT.[MONTH]ORDER BY /*DT.[YEAR],*/DT.[MONTH]
but it returns everything under one another

2005 1 January 2005 3 296092.3431 405263.62 12811 109171.2769 26.93
2005 2 February 2005 3 318597.658 432098.17 13220 113500.512 26.26
2005 3 March 2005 3 371327.721 506481.46 15283 135153.739 26.68
2005 4 April 2005 3 371647.994 504713.99 15491 133065.996 26.36
2005 5 May 2005 3 400870.6138 542759.57 16296 141888.9562 26.14
2005 6 June 2005 3 399673.0086 546110.59 16607 146437.5814 26.81
2005 7 July 2005 3 390477.7521 535531.40 16153 145053.6479 27.08
2005 8 August 2005 3 380628.57 520281.87 15800 139653.30 26.84
2005 9 September 2005 3 340949.8849 471861.17 14820 130911.2851 27.74
2005 10 October 2005 3 340240.804 470007.78 14444 129766.976 27.60
2005 11 November 2005 3 349156.1871 481193.61 14523 132037.4229 27.43
2005 12 December 2005 3 346038.5059 477011.72 14865 130973.2141 27.45
2006 1 January 2006 3 340062.1369 470010.08 14037 129947.9431 27.64
2006 2 February 2006 3 328463.9689 452404.79 13996 123940.8211 27.39
2006 3 March 2006 3 375264.977 517800.27 16065 142535.293 27.52
2006 4 April 2006 3 412708.965 567014.52 17550 154305.555 27.21
2006 5 May 2006 3 446973.4231 606476.26 18920 159502.8369 26.29
2006 6 June 2006 3 406072.4943 544634.77 17053 138562.2757 25.44
2006 7 July 2006 3 389104.6316 526091.14 16228 136986.5084 26.03
2006 8 August 2006 3 317810.4531 431530.58 13641 113720.1269 26.35
2006 10 October 2006 3 405230.7083 549310.72 17151 144080.0117 26.22
2006 11 November 2006 3 379788.6645 514554.14 15917 134765.4755 26.19
2006 12 December 2006 3 393235.0906 531582.69 16924 138347.5994 26.02

If i do get them split then it put every year's value on a different line

2005   1234123.34    32432432.43   NULL   NULL
2006   NULL               NULL           12312.212   15235453.21

Please Help,

View Replies !
[*-)]how To Delete All Columns Except One Column For The Corresponding Column Name......?
hi friends,          i've a table with (columns) username, content,data,........... i need to delete all column names(i.e.,content,data,........) except username for the specified username. eg: consider username=mahendran. i've to delete the values in the content,data,...............for the username=mahendran. but username should exist.how to do that?pls help me...... 

View Replies !
Instead Of Three Columns I Get Only One Column
 
I have a problem with my coding. Here is my code.
 
 



Code Block
WITH AwaitingApprovalCTE AS
(
  SELECT  type = 'Members Awaiting Approval  Yesterday'
        , borrowers  = (select count(*)
                        from LoanApplication
                        where SubmittedOn >= GETDATE()-1)
        , depositors = (select count(*)
                        from CDOrder 
                        where SubmittedOn >= GETDATE()-1)
      , MemberStatus = CuStatus
                    from Member
                  where Custatus = 'Pending'

),

AcceptedCTE AS
(
  SELECT  type = 'Members Accepted  Yesterday'
        , borrowers  = (select count(*)
                        from LoanApplication
                        where SubmittedOn >= GETDATE()-1)
        ,depositors = (select count(*)
                        from CDOrder 
                        where SubmittedOn >= GETDATE()-1)
      , MemberStatus = CuStatus
                    from Member
                  where Custatus = 'Accepted'
),
RejectedCTE AS
(
  SELECT  type = 'Members Rejected  Yesterday'
        , borrowers  = (select count(*)
                        from LoanApplication
                        where SubmittedOn >= GETDATE()-1)
        , depositors = (select count(*)
                        from CDOrder 
                        where SubmittedOn >= GETDATE()-1)
      , MemberStatus = CuStatus
                    from Member
                  where Custatus = 'Denied'
),

combinedCTE AS
(
  SELECT * FROM AwaitingApprovalCTE
  UNION ALL
 SELECT * FROM AcceptedCTE
 UNION ALL
 SELECT * FROM RejectedCTE

)
SELECT   type,
       NoOfMembersJoined = borrowers + depositors
FROM     combinedCTE
 
 


Problem is I get only one field. I get only the first one.i.e. "Members Awaiting Apporval Yesterday"
I dont get other two types.."Members Accepted Yesterday" and "Members Rejected Yesterday".
Final report should look like this:
 
  Type                                                            NoOfMembersJoined
 
Members Awaiting Approval yesterday                       69
Members Accepted Yesterday                                  15
Members Rejected Yesterday                                   31
 
But I get only the "Members Awaiting Approval yesterday" for all the rows.
 
Type                                                              NoOfMembersJoined
 
Members Awaiting Approval yesterday                       0
Members Awaiting Approval yesterday                       0
Members Awaiting Approval yesterday                       0
Members Awaiting Approval yesterday                       0
Members Awaiting Approval yesterday                       0
 
 NoOfMembersJoined = 0 is ok because there may not be any data yet.
 
I can not figure it out why it is. Pease can anyone tell me where I went wrong?

View Replies !
Combine Two Different Columns Into One Column
Hi Guys,
 
I have twotables(Employee and Borrower). In Employee table have EMPID and Borrower table have BorrowerID. I want to comebine these two columns into one column as EMPID  in Employee table. Can  any one help?
Thanks

View Replies !
Searching All Columns Without Using Column Name
Hi,
I am developing a search engine for my application and I need to grab the entire row from the table if I found the search field in any of the columns and the search is not defined to one table. Please let me know how to search all columns in table without using column names indivdually.

View Replies !
Returning 2 Columns As 1 Column
In this query

SELECT E1.id, E2.id
FROM productHeadings AS B1, productHeadings AS E1,
productHeadings AS E2
WHERE B1.id = E1.parent_id
AND E1.id = E2.parent_id
and B1.id = 1

the result is 2 id columns... is there a way to return all id in 1 column?!

View Replies !
Inserting Several Columns Into One Column
I would like to insert several columns into one column.
eg. Coloumn1, Column2 & Coloum3 insert into Column00

thanks, Vic

View Replies !
How To Spit 1 Column Into 4 Columns
I have the data as below
 
Column1
1
2
3
4
5
6
7
8
 
How can I create a query to return
 
Column1       Column2        Column3        Column4
1                   3                   5                   7
2                   4                   6                   8

 
 
Many thanks,

Toan.

View Replies !
Data From Different Columns For One Column
Hi,

I have a tabel called "Daily" which has 5 columns, "TesterID", "Activity", "Hours Given", "Hours Used", "Delta".
The data for "TesterID" and "Hours Given" columns are taken from a table called "Tester".
Data for columns "Activity" and "Hours Used" taken from table called ALD.
"Delta" column is the difference between Hours Given and Hours Used.
For "Hours Given" in table "Daily", the data source should change every 12 hours.
For Monday-Friday Mornings, "Hours Given" should read data from "Tester.Weekdays_day" and for Monday-Friday Nights it should read data from "Tester.Weekdays_Night" and for Saturday-Sunday Mornings it should read from "Tester.Weekend_Day" and for Saturday-Sunday Nights it should read from "Tester.Weekdays_Night" .

How to do that? Please Help. Thank you.

View Replies !
Add A New Column Between Columns In A Table
Can anyone help me how to add a new column between a column in sql server 2005

i have did this one in SQL Server 2000 like below.

1. Add a new column using ALTER statement

2. EXEC sp_configure 'show advanced options',1
GO

RECONFIGURE
GO

EXEC sp_configure 'allow updates',1
GO

RECONFIGURE WITH OVERRIDE
GO

3.Change the colid in syscolumns table using UPDATE Statement

- But its not working in SQL Server 2005...it throws an adhoc error for system catalog table

View Replies !
Compare Two Columns And Update The Third Column
 Hi,I have three columns and want to update the third column based on the comparison of first two columns in the same table.For instance:Col1 - val1, val2, val3, val4, val5......Col2 - NULL, NULL, val1, NULL, val2....Col3 - TRUE, TRUE, FALSE, FALSE, FALSE....Thanks for any help.

View Replies !
SQL Query To One Column Od Database Into Two Columns
Hi,I have a empskill Table which has 3 Columns (1) EmpID (2) SkillTypeID and (3) CourseID.Now  SkillTypeID column has data 1 or 2 .......in here 1 means Primary Skill and 2 means Secondary Skill. CourseID will reflect the ID's of subjects like c#,SQL,etc I need a Query which will count the number of primary skilled and number of secondary skilled persons based on subject and will display as followsCOURSE ID      SKILL TYPE  21                        222                        123                        424                        1IN SHORT:  I want to count the number of particular skill types and display them against their respective course id. You need to display one column data of database into two columns as output. Hope you people will help me in this regard.Thanks in advanceRameshRaj 

View Replies !
Display Multiple Columns Into One Column
My first ASP.NET/SQL project. I'm creating an Asset Management DB. I wish to view the Asset number, the full name of the user it's assigned to and the Make and Model of each record in the DB. However assets are split into different categories e.g. monitors, PCs, Preinters etc. and they are all in different tables. The SQL below displays the asset number, Name of person assigned and the model of the asset.
SELECT Hardware.AssetNo, [User].FullName, MonitorModel.Model, PCModel.Model AS Expr1, PrinterModel.Model AS Expr2
FROM Hardware INNER JOIN
[User] ON Hardware.UserID = [User].UserID INNER JOIN
Model ON Hardware.ModelID = Model.ModelID LEFT OUTER JOIN
MonitorModel ON Model.MonitorModelID = MonitorModel.MonitorModelID LEFT OUTER JOIN
PCModel ON Model.PCModelID = PCModel.PCModelID LEFT OUTER JOIN
PrinterModel ON Model.PrinterModelID = PrinterModel.PrinterModelID
This outputs:-
Asset number     FullName     Model     Expr1     Expr2
00000                User Name   Model     NULL      NULL
00001                User Name   NULL      Model     NULL
00002                User Name   NULL      NULL      Model
However what i hope to acheive is output Model, Expr1, Expr2 into one column like so:-
Asset number     FullName     Model
00000                User Name   Model
Can i do this in the SQL or do i have to do it in my ASP.NET (VB) Page?
Using VSWD 2005 Ex Edition and SQL Server 2005 Ex Edition
Thank you for your replies

View Replies !
UPDATE Column In Table1 From 2 Columns...
Hey ya'll...
I need to create a query that I can run that will allow me to essentially take the first initial and last name and combine them from two columns in one table and update one column with that new data in another table. Example of need:
UPDATE tblLogin.UserName with (first character(tblEmployee.FName)+(tblEmployee.LName)) WHERE tblLogin.EmployeeID = tblEmployee.EmployeeID.
That was TOTALLY pseudo code and I know I'll need a join statement in there somewhere. Both tables reside on the same database, such as this:
dbEMPLOYEE (Database)--> tblLogin (Table)----> UserName (Column)--> tblEmployee (Table)----> FName (Column)----> LName (Column)
Any help would be GREATLY appreciated! Hopefully something soon - this was handed to me a few minutes ago and I have a few minutes to get it done.iSheahan

View Replies !
How To Update Column With Other Columns Ntext Value
i'm aware of using the textptr functions however i'm uncertain how i can set the text value of an ntext column, to another columns ntext value.


thanks for help

View Replies !
How To Update A Column With The Sum Of Two Columns In A Table
 

I have a simple question that is more about performance on my code for updating a column with the sum of two columns:
 
Example
 
Table = dbo.adding
 
c1  c2 c3Sum
1    2    
3    5
4    6
 
Now if I just simple write
 
Update dbo.adding
set c3SUM = c1 + c2
 
This works, but there is a null in c1 or c2 then I know I can write this:
 

if exists (select * from dbo.adding where c1 is NULL)

Update dbo.adding

set c1 = '0', c3SUM = '0' + c2 where c1 is NULL

if exists (select * from dbo.adding where c2 is NULL)

Update dbo.adding

set c2 = '0', equals = c1 + '0' where c2 is NULL

Update dbo.adding

set c3SUM = c1 + c2
 
This works as well, but I am not sure how perficient it is being that from my understanding the code will evaluate the table three times and update it based on the criteria.  If the table consists of 100,000 rows then this might not be a good solution
 
Is there a more proficient way to do this... I personally try to as little coding as possible to help increase performance.  I know I can make this very complex and declare variables and put everything in a loop, but I personally think that would be less profient..
 

View Replies !
Transform One Varchar Column Into Many Bit Columns
Hi all,
I'm new at this SSIS but have been able to successfully create some simple packages.  My situation is that at work we use a column to describe a status of applications.  However, this makes for hellacious query because some of those statuses inherintly were one or more statuses previously. Example
Admit = Admit
Accept = Admit then Accept
Withdraw Accept = Admit, Accept, then Withdraw
Decline = Admit then Decline
As you can see inherintly those were all admits at one point.  So what I'd like to do is instead of having long queries for example to get all my "Admits", I'd rather query another table that has the following columns as bits:
Admit
Accept
Withdraw
That way I can query the admit column and get all my admits.  How can I use SSIS to transform my "Decision" column into those bit columns?
Thanks for any help or suggestions you have.

View Replies !
How To Select All Columns Except One Column From A Table ?
Hi

I can't figure out how to do this and hope you guys can give me a hint....

I want to select all columns from a table except one column:

For example,


A table has 20 columns : {1,2,3.....20}

To select all of columns in a table, i could use
select * from table;

However, I want to select only column {1....19}

I do not want to type the column names in one by one in the SQL query,

is there a way to achieve this in a short form of Select?

Thanks,

View Replies !
How To Display 2 Columns Of Data In 1 Column?
 
How to display 2 columns of Data in 1 column?
 
If I use like this
 
Select Names, 'myData' from emp
 
The output is:
Name1          myData
Name2          myData
Name3          myData
 
But, I need to display like this
 
Name1
myData
Name2
myData
Name3
myData
 
please advise

View Replies !
Returning Multiple Columns From One Db Column
How do I create a select query which returns multiple columns from one actual DB column?

DB structure
ID (int), photo (nvarchar(50)), name (nvarchar(50))

Sample data
1, 'photo1.jpg', 'john smith'
2, 'photo2.jpg', 'jane doe'
3, 'photo3.jpg', 'bob brown'
4, 'photo4.jpg', 'mary brown'
5, 'photo5.jpg', 'sue smith'
6, 'photo6.jpg', 'bob rogers'
...

Required output
pic_col_1, name_col_1, pic_col_2, name_col_2, pic_col_3, name_col_3
photo1.jpg, john smith, photo2.jpg, jane doe, photo3.jpg, bob brown
photo4.jpg, mary brown, photo5.jpg, sue smith, photo6.jpg, bob rogers

Normally, I would just query the data and have the client data loop over the dataset to create the required output, however in this application it is not an option...

Thanks,

Steve

View Replies !
Need New Columns And Random Generating Column
Hi,

i'm importing data from a txt file to Sql server table through a DTS package. the table is created dynamically.

i want three new cloumns added in the front and one of the columns should have a sequence number generation.

Please advice

View Replies !
Want To Map One Flat File Column To Two Db Columns
hi,
on an oledb destination, I want to map one column from a flat file source object to two different columns on the database table.
I only seem to be able to map one to one.
How do I get the pointer to attach to two destination columns?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved