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.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 !
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 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 !
Split A Column Into 2 Columns
Hi everyoneI guess this should be a simple question for the gurusI have a Data in a column which is to be places in 2 columns instead ofone. How do i go about doing it in MS SQL server? Could someone pleasehelp me. I could do it in access with an update query but things are alittle different in SQL server so I am a little lost.Eg.NameJohn?Doeto be split intoName LastNameJohn DoeThanks in advance.Prit

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 !
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 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 !
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 !
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 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 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 !
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 !
How To Split The Field In The Sql Query?
      I have the field LocationID (string)which has values  like
          "AZ001","AZ002","IN002","IN004"  first 2 will be always alphabets and remaining 3 will be numbers,
I want to split it  like "AZ" ," 001"
                              "AZ","002"
                              "IN" "002"
                              "IN" "004"
now i will populate dropdownlist with  unique values of "AZ" "IN"
according to  first dropdownlist how i will populate second dropdownlist?
So how to write sql query for splitting? and then populating the dropdownlist ?
 
 
 
 

View Replies !
Mdx Query Dim?split?left?
:confused:
Hello
i have some problem with this MDX Statment :


with
SET [kunden] as 'Filter (descendants([Dim_x].[Alle Kunden], , LEAVES),
left([Dim_x],1,1) = "(" ) '
select
{descendants([Dim_Kx].[Alle Kunden], , LEAVES) } on rows,
{([measures].[Standard])} on columns


from z
Result :
Standard
(test1) 44444
(test2) 54567
(test3) 3214
test5 4535
test6 11111
but i want to filter i need only result with () how can i do it please
i need help


many thanks,
Prince

View Replies !
Conditional Split Query
 
Hi, 
I have the following table in MsAccess

EmployeesA
empId integer,
empName varchar(60),
empAge integer,
empStatus char(1)  - can be N,D or S - New, Deleted or Shifted
 

and the following in Sql2005
 
EmployeesB
Id smallint,
Name varchar(60),
Age int,
Status char(1) - Bydefault 'N'
 
I have written a Foreach File package that populates the sql server tables (EmployeesB) from Access(EmployeesA). However i want to check for a condition now.
 
If empStatus = N in EmployeesA, then insert a new record in EmployeesB
If empStatus = D in EmployeesA, then search for that field in the EmployeesB by passing empname and age and if found, mark the Status field in EmployeesB as 'D'
If empStatus = S in EmployeesA, then search for that field in the EmployeesB by passing empname and age and if found, mark the Status as 'S' in EmployeesB and insert a new row.
 
How do I do it for each table each row in EmployeesA using a foreach file loop?
 
Thanks,
ron

View Replies !
Need To Query A Database With Distinct Column And Row Counts
On my company site, I have created a database that is for the purpose of tracking google adwords, as well as pages that the user visits.  For instance, if you were to search for "guitars" and then click our ad, an entry is created in the database like thisKeyword:         SessionGUID:         PageVisited:                                                                          VisitedDateTime:Guitars            lkjfeilfjskdlfjsije         ~ViewCategory.aspx?Cat=Guitars,KW=Guitars                       12/01/2000 12:00amGuitars            lkjfeilfjskdlfjsije         ~ViewProduct.aspx?ProductID=1253&SubProductID=3            12/01/2000 12:03amGuitars            lkjfeilfjskdlfjsije        ~Search.aspx?Q=BC%20%Rich                                             12/01/2000 12:05am Pretty much, in our administrative area, I want to be able to have a table that would generate these results: Keyword              Total HitsGuitars                3So im guessing that obviously I would need to do a select distinct for the Keyword column, but how do I also have a column showing a count of the records? 

View Replies !
Split Fields And Display Query Result
Hi,
I'm having a problem in spliting the fields
I need to ru the following query to join two tables and getting the output as shown.

Query:
select cusl.user_name,
pmts.bill_ref_info, pmts.payee_acid, pmts.cust_acid, pmts.txn_amt,pmts.pmt_id
from cusl, pmts
where cusl.ubp_user_id = pmts.ubp_user_id and pmts.ubp_user_id= 'testinglive'

Output:
user_name bills_ref_info payee_acid cust_acid txn_amt
SAMEER ALLA0210181#123456#Amita 378902010021095 383702070051411 1.000 16318
SAMEER BARB0GNFCOM#6788990#Vikram Kalsan 378902010021095 383702070051411 1.000 16327
SAMEER BKID0000200#378902010099678#Vikram 378902010021095 383702070051411 1.000 14031
SAMEER undefined#123456789123456#Vikram 378902010021095 383702070051411 1.000 13918


Now I need to display the second field which is a #-separated field as individual fields alongwith tghe other fields that are shown on execution of the query.
Can this be done? Please guide me on this...

View Replies !
How To Split Data From The MS SQL 2000 Database?
Hi All,

We are working on a project, (C#.Net 2003, MS SQL 2000) where database is growing as 2 to 3 GB per day (Scanned Documents are storing in Database). There is only one table in the database. Currently database size is grown upto 200 GB. For safety reason we are planning to split the database accoring to one key field in the table say Book_no.

Please guide/suggest me how to split the database now on the SQL query like "SELECT * FROM master_records WHERE book_no=1"
And later how to merge/combine all these splitted database into one.
I thought of using "Data Export" and later "Import with Append" but don't know whethere it will effective or not? Any method or tool available to Split the database table and later combine them to make again a single one?

Please help me, its urgent.

Thanks in advance.

View Replies !
Conditional Split For Insert Or Update Cause Dead Lock On Database Level
Hi
 
I am using conditional split Checking to see if a record exists and if so update else insert. But this cause database dead lock any one has suggestion?
 
Thanks

View Replies !
How To Query A Dbo.file Of User-defined Database That Has The &&"nvarch&&" Type In A Column?
Hi all,
In my SQL Server Management Studio Express, I have the following Database "ChemAveRpd", Table "dbo.LabTests", and Content of the Table:
       dbo.LabTests       Column_name        Type         Length        Prec    Scale
                                  AnalyteID                int                4              10         0       (Primary Key)
                                  AnalyteName         nvarch        510
                                  CasNumber           nvarch         510
                                  Result                   numeric          5                8         2 
                                  Unit                       nvarch        510
                                  SampleID                int                4               10         0      (Foreign Key)
 
                            AnalyteID         AnalyteName    CasNumber    Result      Unit      SampleID
                                 1                    Acetone         123-456-9     134.0       ug/L           1
                                 2                    Bezene         666-12-8         2.0        ug/L           1
                                 3                    Cobalt            421-008-7      10.0        ug/L           1
                                 4                    Acetone         123-456-9     201.0       ug/Kg         2
                                 5                    Bezene         666-12-8         1.0        ug/Kg         2
                                 6                    Cobalt            421-008-7      22.0        ug/Kg         2
                                 7                    Acetone         123-456-9     357.0       ug/L           3
                                 8                    Bezene         666-12-8         9.0        ug/L           3
                                 9                    Cobalt            421-008-7      56.0        ug/L           3

 
When I ran the following T-SQL code:
 USE ChemAveRpd

GO

SELECT *

FROM dbo.LabTests as LabResults

Where AnalyteName = Acetone

GO

 
I got the following error:

Msg 207, Level 16, State 1, Line 3

Invalid column name 'Acetone'.
 
Please help and tell me what right syntax I should write for  [Where AnalyteName = Acetone] to generate a listing of LabResults for Acetone.
 
Thanks in advance,
Scott Chang 
 
 

 

View Replies !
Query To Find A Value In Column B Based On An Aggregate Function On Column A?
Hi,Suppose I have a table containing monthly sales figures from my shopbranches:Branch Month Sales-----------------------London Jan 5000London Feb 4500London Mar 5200Cardiff Jan 2900Cardiff Feb 4100Cardiff Mar 3500The question I am trying to ask is this: in which month did each branchachieve its highest sales? So I want a result set something like this:Branch Month----------------London MarCardiff FebI can do a "SELECT Branch, MAX(Sales) FROM MonthlySales GROUP BY Branch" totell me what the highest monthly sales figure was, but I just can't figureout how to write a query to tell me which month corresponded to MAX(Sales).Ideas anyone?Cheers,....Andy

View Replies !
Copy Database With Encrypted Column To New Server And Decrypt Column There
To do this successfully do I need to backup the Service master,  Database master, and database itself from the the Source server, then restore all three of them on the destination server?

(I'm concerned that restoring the source Service Master key to a new target server with an existing sql 2005 install will screw things up big time.)

TIA,

Barkingdog

 

View Replies !
Database Diagrams : Showing Relations Column To Column
Hi to all,
As I am going to deal with a huge number of database tables, I thought that drawing their diagrams will be the most professional way of keeping track of what I am doing. So In Enterprise Manager using the Wizard I made it to be drawn nicely.
 
But I have a problem now. I see that the relations defined among the tables are represented correctly but the line connecting the two table is drawn randomly. I mean the starting point of the line doesnt start from the column having the primary key and doesnt end near to the column having the foreign key. Viewing my diagram I want to see the lines to start and end showing the 2 related key columns.
Is there a way to accomplish this like setting an option, clicking somewhere or should I try to drag the lines to manually?
Thanks in advance

View Replies !
HOW EXCEL COLUMN MAPPE WITH DATABASE COLUMN
 
I have some doubt please help me.
How EXEL data goes into database.
 
Means I have to write a program (Windows application) How EXEL data goes into database.
 
Case 1   I have a database which has a table €˜DEMAND€™
Case 2   and I have to opened the same table €˜DEMAND€™ into excel which has all the column name as in database table €˜DEMAND€™
 
Case 3 exemple: I have opened the same database table into excel

 
 
HOW EXCEL DATA(COLUMN) MAPPEED WITH DATABASE  TABLE(COLUMN) 
 
         

View Replies !
Can A Calc'd Query Column Be Compared Against A Multi Value Variable Without A Nested Query?
do i need to nest a query in RS if i want a calculated column to be compared against a multi value variable?  It looks like coding WHERE calcd name in (@variable) violates SQL syntax.  My select looked like
 
SELECT ... ,CASE enddate WHEN null then 1 else 0 END calcd name
FROM...
WHERE ... and calcd name in (@variable)  

View Replies !
Return Result From One Query As A Column In Other Query
I'm having a bit of a trouble explaining what I'm trying to do here.

I have 3 "source" tables and a "connecting" table that I'm going to use

tblContacts - with contactID, ContactName etc
tblGroups - with GroupID, GroupName
tblSubGroups - with SubGroupID, GroupID and SubGroupName (groupID is the ID for the parent Group from tblGroups)

They are related in a table called
tblContactsGroupConnection - with ContactID, GroupID and SubGroupID

One contact can be related to many subgroups.
What I want is a list of all contacts, with their IDs, names and what groups they are related to:

ContactID, ContactName, [SubGroupName1, SubGroupName2, SubGroupName3]
ContactID, ContactName, [SubGroupName1, SubGroupName3]
ContactID, ContactName, [SubGroupName3]

I'm sure there's a simple solution to this, but I can't find it. Any help appreciated. :)

Kirikiri

View Replies !
Sql Query With One Column As The Name To Another Column
Hi ThereDoes anyone know how to create a query or do something in a storedprocedure to output one column as the other columns name? The output Iwant is something like this:CurrentMonth(Jun 05) May 05 April 05ItemCode Units Price Units Price Units PriceA 10 10.00 5 8.00 12 12.00The month displayed as the column names will be in fieldsCurrentMonthDesc, SalesHistoryDesc1, SalesHistoryDesc2 etc. Now I wantthese to be the headings to Current, SalesHistory1, SalesHistory2 etc.Please help!Kind RegardsMarlene

View Replies !
How To Sum A Column In A SQL Query
Can someone tell me how to sum values in a column from a resultant Query. For example, consider this query which in partcalls a view named "Rpt_OverallIndMarket"
select * from Rpt_OverallIndMarket order by MarketId,Year,Quarter
The resultant query from the previous query will contain a column named TotalSquareFeet. How do I sum all of the TotalSquareFeet values inthat column?

View Replies !
Query Same Column Twice
Hi, I'm pretty sure that I've missed something obvious but I can't think of what it is, I need to get rows where "forid" is 0 and 1 but I can't think of how to do it, I tried:

SELECT * FROM `events` WHERE `forid` = '0' AND `forid` = '1'

But that query isn't correct.

Appreciate any help, thanks.

View Replies !
Add Sum Column To Query
What's the best way to include an amount sum in a query if I also need the individual amounts? For example, I need the following columns:

order number

order amount

total amount

 

I tried using  "with cube ", but the total number of columns in the query exceeds the allowable limit of 10.

View Replies !
Query Against XML Column
My XML column is like below.
 

<rs:CheckPointExpressIDNotRequired xmlns:rs="urn:release-schema">

<rs:IsJavaRuling>True</rs:IsJavaRuling>

<rs:IsGeoPolitical>True</rs:IsGeoPolitical>

<rs:IsConsentDecree>True</rs:IsConsentDecree>

<rs:HasThirdPartyBits>False</rs:HasThirdPartyBits>

<rs:MandatoryLicenseAgreement>Verified</rs:MandatoryLicenseAgreement>

</rs:CheckPointExpressIDNotRequired>

 
 

My query is below.
 
SELECT

ref.value('IsJavaRuling[1]', 'varchar(36)') as [IsJavaRuling]

FROM REQUESTCOMPLIANCE CROSS APPLY xml.nodes ('//CheckPointExpressIDNotRequired') R(ref)

order by lastmodifieddate desc
 
 
My query runs successfully but I am not getting any results back however there are many rows to be returned. Can you tell me what is wrong with the query?
 
Thanks,
Koti

View Replies !
Return The Results Of A Select Query In A Column Of Another Select Query.
Not sure if this is possible, but maybe. I have a table that contains a bunch of logs.
I'm doing something like SELECT * FROM LOGS. The primary key in this table is LogID.
I have another table that contains error messages. Each LogID could have multiple error messages associated with it. To get the error messages.
When I perform my first select query listed above, I would like one of the columns to be populated with ALL the error messages for that particular LogID (SELECT * FROM ERRORS WHERE LogID = MyLogID).
Any thoughts as to how I could accomplish such a daring feat?

View Replies !
Invalid Column Name From C# Sql Query
 Hi I have the following problem. I am trying to get some data from a database which matches the name in a session from a previous page:e.g.        SqlCommand menubar = new SqlCommand("Select pernme from Person where pernme = " + (string)Session["tbname"], sqlConn);            SqlDataAdapter dataAdapter5 = new SqlDataAdapter();            dataAdapter5.SelectCommand = menubar;            DataSet dataSet5 = new DataSet();            dataAdapter5.Fill(dataSet5);            DataTable selcartest4 = dataSet5.Tables["table"];            if (selcartest4.Rows.Count != 0)The session is called tbname and in that session is a users name however insetad of doing the nornal thing and retrieving the data in the sql database table matching that name it comes up with the following error message:System.Data.SqlClient.SqlException: Invalid column name 'jamie'this is weird as the 'jamie' is the name in the session from the previous page and in fact not a column name at all the column name is pernme  I am totally stuck any help would eb great thanksJ 

View Replies !
SQL Query To Join A Column On A Row
I have 2 tables, my vehicle data table and my config table. I need a
query to join them by a datarow and a data column. Heres my tables...config table--------------------id   name   type--------------------1    make   varchar2    model  varchar3    color  varcharveh table--------------------------id   make   model   color--------------------------1    chevy  s10     white2    ford   ranger  silver2    chevy  blazer  brownrecordset needed for veh.id=1---------------------------id   name   type     value---------------------------1    make   varchar  chevy2    model  varchar  s103    color  varchar  white  Thanks for any helpRyan 

View Replies !
Using A Variable For A Column Name In A Query
Is it possible to use a column name variable in a Select Statement for a column name?For example I have a dropdown with FName,LName,Phone and a text box. The user can select the field to search and the criteria will go into the text box. The problem is the select doesn't like a variable for the field name. I have tried both a standard variable and a Case statement (see below). This is being used in a Stored Procedure with MSSQL. The actual select is much more complicated than this but it gets the point across. Thanks for your help in advance@Field as varchar( 50),@Value as varchar (50)SELECT *FROM customersWHERE @Field = @ValueORSELECT *FROM customersWHERE      CASE WHEN @Field = 'Fname' THEN Fname = @Value END,     CASE WHEN @Field  = 'Lname' THEN Lname = @Value END,     CASE WHEN @Field  = 'Phone' THEN Phone = @Value END;

View Replies !
Column Name As The Result Of A Query?
Simple example would look like that in MS SQL

SELECT 'a' AS (SELECT language_name FROM language WHERE language_id = 1)

So that the display is

English
a

as we assume that

SELECT language_name FROM language WHERE language_id = 1

returns only English

I have tried to that with a variable but it does not work

declare @that as varchar(15);
set @that = (select language_name_u from language where language_id = 1);
select 'a' as @that

LOL

I just tried another way as i was going to post

declare @that as varchar(15);
set @that = (select language_name_u from language where language_id = 1);
select 'a' as "@that"

and it worked!

Posting anyway so people might answer with a better solution with no variable

Thanks a lot

Mordan

View Replies !
AND Query In Single Column
Hi groupI have a rather peculiar question, and I really don't know how to solvethis within an SQL statement:Given a view (v), that results in:IDX-----------------1a1b2a2c3aI'd like to query the view with something like:SELECT ID FROM v WHERE (X='a' AND X='b') which would result in:ID-----------------1or in another case:SELECT ID FROM v WHERE (X='a' OR X='c')would give:ID-----------------123how can this be done?TIAbernhard--www.daszeichen.chremove nixspam to reply

View Replies !
How To Query For A Column Value That Contains Dashes
Hi,I have a large table with a 'datetime' column that has date and timevalues in it. The data is in this format:2007-10-02 09:54:00.000The table is called 'profile' and the column 'msgdate'I want to return only rows that match a specific date. So far I havethe following query working:select * from profile where msgdate like '%2007%'This returns all rows that start with '2007'. However I cannot seem toge the syntax that will allow me to return a specific date, e.g.2007-10-02I have researched this, trying all sorts of queries with escapecharacters/sequences because of the dash character, but I cannot getit to return anything. Most of my queries have ran without error, itsjust that no data is returned.James

View Replies !
Hidding Column In Query
Here is my code.SELECT [Owner].[First Name], [Owner].[Last Name], [Condo].[Unit Number],[Condo].[Weekly Rate], [Condo].[Linens]FROM [Owner], [Condo]WHERE [Condo].[Linens]=TrueAND [Owner].[Owner ID]=[Condo].[Owner ID]ORDER BY [Condo].[Unit Number];I am trying to not display "Linens" column in my query result.Any idea howcan i achive that. Thanks in advance

View Replies !
Query To Get Column Name With Specific Value
Here is tested schemaif exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[TestTable]') and OBJECTPROPERTY(id, N'IsUserTable')= 1)drop table [dbo].[TestTable]GOCREATE TABLE [dbo].[TestTable] ([SerialNumber] [char] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,[test1] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test2] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test3] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[test4] [char] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ON [PRIMARY]GOinsert into testtable values ('123','pass',null,'fail','skip')insert into testtable values ('456','fail',null,'pass','skip')insert into testtable values ('789',null,'fail','skip','pass')insert into testtable values ('345','pass','pass','pass','fail')I would like to fetch the COLUMNNAME where the value is fail.Basically I need to know which test failed, test1, test2, test3 ortest4?Is this possible?

View Replies !
Query Column With Letters
I have a database with a zip code column. I want to flag all rows that have letters in that column (a-z). How could I construct the where clause?

Is there a better alternative to:
WHERE ZipCode LIKE '%a%' OR ZipCode LIKE '%b%' ...

View Replies !

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