Need New Columns And Random Generating Column

Aug 31, 2006

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 2 Replies


ADVERTISEMENT

How To Make 2 Columns In Datagrid With Random Records?

Aug 20, 2005

Hi

I want to make random record from both columns

Not just like this
"SELECT Firstname,Lasename FROM rndnames ORDER BY NewID()"

but more like this but this code dont work becouse i dont know how to put it into the code:
"SELECT Firstname FROM rndnames ORDER BY NewID()"
"SELECT Lasename FROM rndnames ORDER BY NewID()"

As you see i want both columns to be random placed..

Please help me...

View 1 Replies View Related

TSQL - Generating New Column With The Maximum Value Of Other Column

Dec 2, 2007

Hi guys,
In the query below, I need to insert a new Column that shows the last Document date.
In example,
Document Date Last Date
2006/01/15 2007/11/30
2007/03/25 2007/11/30
2007/11/30 2007/11/30
I need to show the last (max) date for each row.
Thanks in advance for any help,
Aldo.




Code Block
SELECT
Stock.VALUEDATE AS 'Document Date'

FROM
Stock As Stock
INNER JOIN ACCOUNTS AS Accounts
LEFT OUTER JOIN ACCSORTNAMES AS AccSortNames ON Accounts.SORTGROUP = AccSortNames.ACCSORTCODE
LEFT OUTER JOIN EXTRANOTES AS ExtraNotes01 ON Accounts.ACCOUNTKEY = ExtraNotes01.KEF AND ExtraNotes01.NOTEID IN ('17')
LEFT OUTER JOIN EXTRANOTES AS ExtraNotes02 ON Accounts.ACCOUNTKEY = ExtraNotes02.KEF AND ExtraNotes02.NOTEID IN ('18') ON Stock.ACCOUNTKEY = Accounts.ACCOUNTKEY
INNER JOIN DOCUMENTSDEF AS DocumentsDef ON Stock.DOCUMENTID = DocumentsDef.DOCUMENTID

WHERE
Accounts.SORTGROUP Between '0' AND '379' AND
Accounts.SORTGROUP Not Between '100' AND '150'
AND Stock.DOCUMENTID In ('1', '4', '5', '11', '78', '95')
AND Stock.STATUS Not In ('0', '2')
AND Accounts.SORTGROUP Between '0' AND '379'
AND Accounts.ACCOUNTKEY Like '313%'

View 10 Replies View Related

Generating Seq No With In A Main Column

Jul 20, 2005

Hi all,please see if some one can suggest a better approach for this.i need to move 5 million rows from one table to another.LoanID is the only clumn in Source tableSource table structure=========-->==============================loanID1122234=====================================target or detination table should look like this=========================================loanID Sqeuence_number_with_in_LoanID1 11 22 12 22 33 14 1=========================================this is what i have tried so far1)there are about 4 & 1/2 million out of 5 million which will appearonly once (this is one tine load) in source table.so if i do this-----------sleect loanIDfrom SourceTablegroup by loanIDhaving count(*)=1and then i will hard code Sqeuence_number_with_in_LoanID to 1 .becausei know they will only come once.this is set based operation so this isfast.2)now,problem is with remainder of the 1/2 million rows.i had to use cursor for this which is very-very slow.other option i was thinking of is to pull it in the front end(.net)and do it there.i am hoping that will be faster.Database i am working on is sql server 2000.if some could suggest me some better approach of handling thisremainder1/2 milion rows.thanks in advance-sidd

View 4 Replies View Related

Random Ambiguous Column Name Error

Mar 7, 2008

Hi

I have a query that is exhibiting a strange behaviour on different databases.

I've got something like this ...


select a.col, ...
from tab1 as a inner join ...
union
select a.col, ...
from tab1 as a inner join ...
order by col

I know how to fix the problem, I make the last line read "order by a.col" ... that is understood.

However, on some databases I get an error and on others I don't. All databases are on the same server instance which is sql server 2005 developer (developer version isn't relevant as it happens on customer machines too).

I'm just wondering if anyone has any ideas why it is 'random'. It's as though the statement is being compiled differently on different databases ... what is influencing that ?

I'm fishing for a way to create a workaround, so if anyone has any ideas it might push me down the road of understanding why.

The real code is way too big to include here and it's not really relevant.


As a clue to what I'm looking for, if I copy the database to another database using SSIS, the resultant database doesn't cause the error despite being logically the same.

Presumably it is some physical or security difference that is causing the error to occur.

Thanks if you have any ideas,

Richard.

View 5 Replies View Related

Auto Generating Numeric Column

Sep 5, 2006

Hi There,I want to create a column that usto numbers upto a specified value, and the resets. I've tried using the identity column and then using DBCC CHECKIDENT, but this doesnt doesn't have the desired affect. Here's an example of what I'm after.AutoRow1234 -------- reset1234 --------resetAny help would be great, many thanksStuart   

View 5 Replies View Related

How To Assign Random Number To One Column For 500 Records?

Aug 4, 2005

I try to set up a testing sample table which contain one  integer project_ID field for table Sample around 500 records, and want the project_ID to be random number within 1 to 99, how to implement script todo it?
thanks!

View 1 Replies View Related

Sorting Matrix Column In Random Order

Aug 14, 2007



Hi,

I have a matrix report...the column results
are as follows

Con Std , Con Access, SF Std, SF Acc, Broadband, Pay TV

how would i make the columns appear in the above order when displaying as it is default alphetically sorted...I have tried putting numbers at the front which work till I get to the number 10 which alphetically sorted is next to 1 not 9?
is there a better way off sorting matrix column which have no specific criteria to sort from?

thanks

View 6 Replies View Related

Inputting Random Numbers To Table Column From Web Form

Feb 28, 2007

I'm grappling with this issue which I thought was basic VB programming; I'm trying to insert a random number (between 100 and 999) into a SQL table column (=Status_ID). This is input as part of a user submitting helpdesk requests via a APS.Net Web Form. The 'Status_ID' field is obviously not visible to the user but will help reference this Helpdesk request on the database.Here is the code:Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click        If Page.IsValid Then            ' Define data objects            Dim conn As SqlConnection            Dim comm As SqlCommand            ' Read the connection string from web.config            Dim connectionString As String = _            ConfigurationManager.ConnectionStrings("ITNet_Students").ConnectionString            ' Initialize connection            conn = New SqlConnection(connectionString)            ' Create command            comm = New SqlCommand( _            "INSERT INTO HelpDesk (First_Name, Last_Name, StudentID, PersonalEmail," & _            "CategoryID, SubjectID, Description, StatusID) " & _            "VALUES (@First_Name, @Last_Name, @StudentID, @PersonalEmail, " & _            "@CategoryID, @SubjectID, @Description, @StatusID)", conn)            ' Use randomize            Randomize()            Dim randomvalue As Integer            ' Generate random value between 999 and 100.            randomvalue = Int((900 * Rnd()) + 100)            ' Add command parameters            comm.Parameters.Add("@First_Name", System.Data.SqlDbType.NVarChar, 50)            comm.Parameters("@First_Name").Value = fnameTextBox.Text            .            .            .            comm.Parameters.Add("@StatusID", System.Data.SqlDbType.Int)            comm.Parameters("@StatusID").Value = randomvalue            'Enclose database code in Try-Catch-Finally            Try                ' Open connection                conn.Open()                ' Execute the command                comm.ExecuteNonQuery()                ' Reload page if the query executed successfully                Response.Redirect("HelpDesk.aspx")            Catch                ' Display error message                dbErrorMessage.Text = _                    "Error submitting the help desk request! Please try again later, and/or change the entered data!"            Finally                'close connection                conn.Close()            End Try        End If    End Sub----------------------------------------------------------------------------------------------------------------------I keep getting the error message under 'Catch'  and the page 'HelpDesk.aspx' is not reloading; the 'comm.ExecuteNonQuery()' is not executing.Can anyone spot any inconsistencies in the declaration of the 'randomvalue' variable?P.S: this code works fine if you replace 'randomvalue' with any integer in 'comm.Parameters("@StatusID").Value = randomvalue' 

View 2 Replies View Related

Returning Random Records And NOT Similar (random Questions)

Jul 20, 2005

Hi,I need to extract randomly 5 records from the table "Questions". Now I useSELECT TOP 5 FROM Questions ORDERBY NEWID()And it works. The problem is that I need an additional thing: if SQLextracts record with ID=4, then it should not extract record with ID=9,because they are similar. I mean, I'd like something to tell SQL that if itextracts some questions, then it SHOULD NOT extract other ones.How can I do it?Thanks!Luke

View 1 Replies View Related

Random Selection From Table Variable In Subquery As A Column In Select Statement

Nov 7, 2007

Consider the below code: I am trying to find a way so that my select statement (which will actually be used to insert records) can randomly place values in the Source and Type columns that it selects from a list which in this case is records in a table variable. I dont really want to perform the insert inside a loop since the production version will work with millions of records. Anyone have any suggestions of how to change the subqueries that constitute these columns so that they are randomized?




SET NOCOUNT ON


Declare @RandomRecordCount as int, @Counter as int
Select @RandomRecordCount = 1000

Declare @Type table (Name nvarchar(200) NOT NULL)
Declare @Source table (Name nvarchar(200) NOT NULL)
Declare @Users table (Name nvarchar(200) NOT NULL)
Declare @NumericBase table (Number int not null)

Set @Counter = 0

while @Counter < @RandomRecordCount
begin
Insert into @NumericBase(Number)Values(@Counter)
set @Counter = @Counter + 1
end


Insert into @Type(Name)
Select 'Type: Buick' UNION ALL
Select 'Type: Cadillac' UNION ALL
Select 'Type: Chevrolet' UNION ALL
Select 'Type: GMC'

Insert into @Source(Name)
Select 'Source: Japan' UNION ALL
Select 'Source: China' UNION ALL
Select 'Source: Spain' UNION ALL
Select 'Source: India' UNION ALL
Select 'Source: USA'

Insert into @Users(Name)
Select 'keith' UNION ALL
Select 'kevin' UNION ALL
Select 'chris' UNION ALL
Select 'chad' UNION ALL
Select 'brian'


select
1 ProviderId, -- static value
'' Identifier,
'' ClassificationCode,
(select TOP 1 Name from @Source order by newid()) Source,
(select TOP 1 Name from @Type order by newid()) Type

from @NumericBase



SET NOCOUNT OFF

View 14 Replies View Related

SQL 2012 :: Generating Date Range Values (start / End Dates) From Month Columns With Boolean Values

Jan 13, 2015

I've got some records like this:

ID_________Jan Feb...........................Dec
0000030257 0 0 0 0 0 0 1 1 1 1 1 0

where each month field has a 0 or 1, depending on if the person was enrolled that month.

I'm being asked to generate a table like this:

ID_________ Start_Date End_Date
0000030257 July 1, 2014 Nov 30, 2014

Is there some slam dunk way to do this without a bunch of If/Then statements?

The editor compressed all my space fields, so the column headers are off in some places.

View 8 Replies View Related

Invalid Column Name 'rowguid'. Error When Generating Snapshot For Merge Replication SQL Server 2005

May 15, 2007

Hi there,



I have setup merge replication which successfully synchronizes with a group of desktop users using SQL Compact Edition.



However now I have setup Article Filters and when I attempt to regenerate the snapshot I get the following error:



Invalid column name 'rowguid'.

Failed to generate merge replication stored procedures for article 'AssignedCriteria'.



When I look at publication properties at the Articles page.. All my tables have the rowguid uniqueidentifier successfully added to tables and selected as a compulsory published column, apart from the table above "AssignedCriteria".. Even when I attempt to select this column in the article properties page and press ok, when I come back it is deselected again. ( The Rowguid column is however physically added to the table)



I have scripted the publication SQL and then totally reinstalled from scratch, including the database but for some reason it doesn't like this table. I remove the article filters, but still this "rowguid" is never "selected" in article properties.



We are using Uniqueidentifiers in other columns as well for historical reasons, but this doesn't appear to be a problem in other tables..



DDL For this problematic table is as follows



CREATE TABLE [dbo].[AssignedCriteria](

[AssignedCriteria] [uniqueidentifier] NOT NULL,

[CriteriaName] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[TargetScore] [numeric](5, 0) NULL,

[HRPlan] [uniqueidentifier] NULL,

[ActualScore] [numeric](18, 0) NULL,

[Criteria] [uniqueidentifier] NULL,

[Employee] [uniqueidentifier] NULL,

[IsActive] [bit] NULL,

[addDate] [datetime] NULL,

[totalscore] [numeric](5, 0) NULL,

[isCalc] [bit] NULL,

[Weight] [decimal](18, 2) NULL,

[ProfileDetail] [uniqueidentifier] NULL,

[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [MSmerge_df_rowguid_7FF25DF903B6415FBFF24AC954BC88E4] DEFAULT (newsequentialid()),

CONSTRAINT [PK_AssignedCriteria] PRIMARY KEY CLUSTERED

(

[AssignedCriteria] ASC

)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]



Thanks.



View 5 Replies View Related

URGENT - Random 10 From Random 20 (2 Tbls)

Oct 14, 2004

I'm using ASP and SQL Serv 2000. What I need to get from 2 tables (company & customers) is random 10 customers from random 20 comp.
Anyone got an idea how to do this??? I've spent 2 days trying to get stored proc. or T-SQL to work, but nothing good came out of it. I can get 1 comp and 10 cust, but not a grouped list of 20 comp. w/ 10 cust. each.

Help is greatly appreciated.

View 1 Replies View Related

How Can I Set Constant Padding Between The Columns Of The Column Chart(stacked Column Sub-type)?

Aug 2, 2006

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

SUM Of One Column To Multiple Columns Based On Another Column Value

Oct 14, 2015

LeaveEntitlementID PeriodID LeaveType EmployeeID NumberOfDays

1 1 Annual 1 10
2 1 Annual 1 10
3 1 Sick 2 10
4 2 Sick 2 10
5 2 Sick 2 10

I have the above table (LeaveEntitlement) which has the above columns.

What I want to sum the column NumberOfDays based on EmployeeID, LeaveType and PeriodID columns as of LeaveTypeNumberOfDays.

For example sum(NumberOfDays) where PeriodID=1 and EmployeeID=1 and LeaveType=Annual

The result should be shown in new column name AnnualLeave (20)

sum(NumberOfDays) where PeriodID=1 and EmployeeID=1 and LeaveType=Sick

The result should be shown in new column name SickLeave (10)

Same all leave Types

The table should be shown as the below after executing the query

LeaveEntitlementID PeriodID EmployeeID AnnualLeave SickLeave

1 1 1 20 0
2 1 2 0 10
3 2 2 0 20

is it possible in sql server

View 8 Replies View Related

[*-)]how To Delete All Columns Except One Column For The Corresponding Column Name......?

Jul 15, 2007

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

Add New Column In Between Other Columns (was Is It Possible)

Sep 20, 2005

Hi all

can we add a new column in a table inbetween other columns.

Sachin

View 5 Replies View Related

Instead Of Three Columns I Get Only One Column

Oct 25, 2007


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

Combine Two Different Columns Into One Column

May 30, 2008

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

Searching All Columns Without Using Column Name

Dec 30, 2003

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

Inserting Several Columns Into One Column

Mar 15, 2000

I would like to insert several columns into one column.
eg. Coloumn1, Column2 & Coloum3 insert into Column00

thanks, Vic

View 1 Replies View Related

Returning 2 Columns As 1 Column

Oct 30, 2006

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

Select Max Int Column And Other Columns

Feb 27, 2015

I have three records, with one column that is an identity/PK. I want the last record inserted and the whole record's information from the query, using a where clause to limit the record returned from the table.

I get an error if I do not have the group by added. However, with this query, I still get three records returned.

SELECT max([tablePK])
,[orderGUID]
,[tblPeopleFK]
,[tbl_shippingAddressFK]
,[tblBillingMethodFK]
,[shippingMethod]

[Code] ....

View 1 Replies View Related

Data From Different Columns For One Column

Mar 7, 2008

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

Add A New Column Between Columns In A Table

Mar 11, 2008

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

Split A Column Into 2 Columns

Jul 23, 2005

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

How To Spit 1 Column Into 4 Columns

Apr 29, 2008

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

UPDATE Column In Table1 From 2 Columns...

Jan 22, 2007

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

Query Split Column In 2 Columns In SQL

Jan 22, 2008

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

Split One Column Into Multiple Columns

Jan 28, 2008

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

Display Multiple Columns Into One Column

Feb 5, 2008

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

SQL Query To One Column Od Database Into Two Columns

Mar 27, 2008

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







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