Newbie Needing Help With Joining 2 Fields

Feb 12, 2007

I have a sql 2005 dev ed running an application developed in vs.net 2005 C# I have several gridviews which have a field call first name and a field called lastname I need to put both the firstname and lastname in the same cell or colum row. I do not now how to join these. Can some one help me with a SQL query string that will do this for me.

View 2 Replies


ADVERTISEMENT

Newbie Needing Help With Sql Script

Apr 10, 2007

I keep getting this error on this script can some one help me out.
There is an error in the query. The data types varchar and sql_variant are incompatible in the add operator.The multi-part identifier "LANGUAGES.DESCRIPTION" could not be bound.The multi-part identifier "LANGUAGES.DESCRIPTION" could not be bound.
 
SELECT 'Quarter All' as 'qtr',       COUNT(JOB.JOBID) as 'transcount',       COUNT(DISTINCT JOB.PATIENTID) as 'patient count',       SUM(JOB.LANGUAGE_TCOST) as 'lcost',       SUM(JOB.LANGUAGE_DISC_COST) as 'dlcost',       AVG(JOB.LANGUAGE_DISC) as 'avgLDisc',       SUM(JOB.LANGUAGE_TCOST) + SUM(JOB.LANGUAGE_DISC_COST) as 'LGrossAmtBilled',       SUM(JOB.LANGUAGE_TCOST) / COUNT(DISTINCT JOB.PATIENTID) as 'PatAvgL',       SUM(JOB.LANGUAGE_TCOST) / COUNT(JOB.JOBID) as 'RefAvgL',       SUM(JOB.LANGUAGE_DISC) as 'avgPercentDiscL',       JOB.JURISDICTION,       PAYER.PAY_COMPANY,       PAYER.PAY_CITY,       PAYER.PAY_STATE,       PAYER.PAY_SALES_STAFF_ID,       JOB.INVOICE_DATE,       JOB.JOBOUTCOMEID,       JOB.SERVICEOUTCOME,       INVOICE_AR.INVOICE_NO,       INVOICE_AR.INVOICE_DATE AS EXPR1,       INVOICE_AR.AMOUNT_DUE,       INVOICE_AR.CLAIMNUMBER,       LANGUAGES.DESCRIPTION      
FROM JOB        INNER JOIN INVOICE_AR                ON JOB.JOBID = INVOICE_AR.JOBID       LEFT OUTER JOIN PAYER                ON PAYER.PAYERID = JOB.PAYERID       LEFT OUTER JOIN STATES                ON JOB.JURISDICTION = STATES.INITIALS
WHERE      (INVOICE_AR.AMOUNT_DUE > 0)AND       (INVOICE_AR.INVOICE_DATE BETWEEN @startdate and @enddate)AND         (MONTH(INVOICE_AR.INVOICE_DATE) IN (1,2,3,4,5,6,7,8,9,10,11,12))AND         (PAYER.PAY_COMPANY like '%' + @Company + '%')                Group By        JOB.JURISDICTION,        PAYER.PAY_COMPANY,        PAYER.PAY_CITY,        PAYER.PAY_STATE,        PAYER.PAY_SALES_STAFF_ID,        JOB.INVOICE_DATE,        JOB.JOBOUTCOMEID,        JOB.SERVICEOUTCOME,        INVOICE_AR.INVOICE_NO,        INVOICE_AR.INVOICE_DATE,        INVOICE_AR.AMOUNT_DUE,        INVOICE_AR.CLAIMNUMBER,        LANGUAGES.DESCRIPTIONOrder By 'QTR' asc

View 4 Replies View Related

Newbie Needs Help On Joining Query

Oct 11, 2007

Hi All,

First off sorry for my complete lack of experience with SQL, but I've just started a new position which involved learning SQL. I'm currently looking for a course but in the mean time I just have to try and fumble by doing basic things.

I'm trying to write my first basic select / join statement, and I just can't seem to get it working.

Any help would really be appreciated. It's T-SQL we use btw.

Thanks :)



USE MLSDHeat
GO

select * from dbo.CallLog
where callstatus between 'open'and 'pending'
right outer join dbo.Asgnmnt
on callid = callid
order by callid



--the above returns error Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'right'.

View 2 Replies View Related

Joining On Datetime Fields

Jul 26, 2002

I am trying to join two tables and the datetime fields need to be part of the join. They contain times in the fields too. I just need them to join on the date part though. Is there maybe a way to just return the mm/dd/yyyy format and join on that? Any and all help is appreciated.

Thanks,
Chris

View 2 Replies View Related

Joining Two Fields In A Query

Apr 26, 2006



I am trying to join two fields in a query in SQL 2000. For example.

Update myTable SET field_1 = @field_1_value , field_2 = @field_2_value, field_3 = @field_1_value + ' x ' + field_2_value



Is this even possible.

I want the user to input values for fields 1 and 2, then in the background combine the two and insert that value in field 3.



Thanks in advance,

Scotty_C

View 7 Replies View Related

Q On Joining Tables With Nullable Fields

Sep 27, 2006

Question.I have a new table that I am adding to a script that I wrote. Thistable has 3 fields, the first 2 fields are used in the on statement asbeing = other fields in the script.The first field always has data in it, but the 2nd field is sometimesnull.So my problem is if both fields have data in them and they both matchto the data in the fields that I am linking them to, then it returnsthe 3rd field without a problem. However if the 2nd field is null thenit is returning a null for the 3rd field. I have checked and the fieldthat I am linking to is null also.So if I haveselect t1.field1, t1.field2, t2.field1, t2.field2, t2.field3from table1 t1join table2 t2on t1.field1=t2.field1 and t1.field2=t2.field2with 2 records in each tabletable1: record1: data, datarecord2: data, nulltable2: record1: data,data,datarecord2: data,null,datawhat I get from the script isrecord1: data, data,data,data,datarecord2: data,null,data,null,nullI would expectrecord2: data,null,data,null,dataI hope this makes sense, I didn't want to post the entire actual scriptas it is about 150 lines long.Thanks in advance.

View 5 Replies View Related

Joining Two Fields To Single Field

Jun 14, 2006

If I have a database table with the following columns:
ID
Other_ID
Description

And I want to join the two ID fields to one field in another table that contains the following fields:
ID
Name

How would i do that?

Here is some sample data and what I would like returned

TABLE1

ID Other_ID Description
row 1 1 2 Number1
row 2 3 1 Number2

TABLE2

ID Name
row 1 1 John
row 2 2 Bob
row 3 3 Bill

I want to query TABLE1, row 1 so that I pull back the Names for the values stored in the ID and Other_ID fields so that my results are like:
John Bob Number1

The only way around it now is that I store Other_Name in Table1.

Thanks.



View 4 Replies View Related

Joining / Concatenating Fields - Unique Reference?

Jun 13, 2014

I have a simple query which displays items from inventory with their latest annual test date. I want to create another unique reference in my results to use as a certificate number. The number should be a combination of the item+month+year from the test date. What is the easiest way to accomplish this?

My query and my desired results are below:

select item, test_date
from inventory
where cat = 'TELE' and itemised_status > 15

item test_datecert_no
-------------------- ----------------------------------------
05MC0002 2014-06-10 00:00:0005MC0002-06-2014
06MT0001 2014-05-13 09:02:0006MT0001-05-2014
06MT0002 2014-05-13 09:03:0006MT0002-05-2014
06MT0003 2014-05-13 09:03:0006MT0003-05-2014
06MT0004 2014-05-09 14:12:0006MT0004-05-2014

View 2 Replies View Related

JOINing On CHAR Fields Of Different Field Lengths

Nov 30, 2007

Can someone comment on why joining two tables on CHAR fields of different lengths would generate unexpected results?

I had an issue where I ran an update that used an inner join on two tables. The field I used in the join was char(50) in one table and char(13) in another table. The result gave bad matches. After changing the field types both to varchar(30), the problem was eliminate.

Any comments on this would be appreciated.



Rye Guy

View 3 Replies View Related

SQL Server 2012 :: Joining Table To Itself To Get Most Recent Date As Well As Additional Fields

Mar 11, 2014

I am querying a table log file in an attempt to get the most recent status of an item. The items can have a variety of different statuses:

(A = Active, R = Repeat, L = liquidation......)

Here is a sample of the data I am trying to report off of:

CREATE TABLE [dbo].[item_status](
[item_number] [varchar](20) NULL,
[sku] [varchar](100) NULL,
[Field_Name] [varchar](50) NULL,
[Old_Value] [varchar](150) NULL,
[New_Value] [varchar](150) NULL,
[Change_Date] [smalldatetime] NULL
) ON [PRIMARY]

[code]...

I have tried join to the same table - but I am still unable to get it to work.

View 1 Replies View Related

Needing Help

Oct 15, 2007

Hello I'm just learning SQL, here's my problem. I have two tables. I'm trying to extract information from table 1. The information I'm trying to get is data that doesn't have a link on table 2. So for example trains is table 1 and train cars is table 2, All the trains have a car except one. How do I get that train without bringing up all the rest.

View 3 Replies View Related

Neebie Needing Help Asap Restoring Sql

Jun 25, 2007

I am having  problem which is getting worst by the moment. I had a power failure which my battery backup fail while running a large report in my SSRS all of a sudden I started getting reportservertempdb.dbo.persistedstream error. I could not get my reports to run through the iis webservice. I could get them to run from within my reportbuilder. I was told to reload my sql and restore it but I can not get my sql to successfully reinstall I am using the sql2005 dev ed. It either gives me a name instance issue or fails the database, report server and notifaction portion of the reload. I am not sure why it will not reload. any assistance would be great.

View 1 Replies View Related

Query Needing Sum Function/group By?

Apr 24, 2008

select bicycle_shop.bicycle_shop_id, bicycle_shop.company_name, order_.unit_price
from order_ inner join bicycle_shop on order_.order_serial_number = bicycle_shop.order_serial_number
order by order_.unit_price DESC;

this query will bring up a few records for each shop, of the one or more bikes they bought and each bike's price, how do i have these come out to a sum(of the price), so that each bike shop will have a sum of revenue. someone told me i need to use group by and the sum function but i dont know how

View 5 Replies View Related

Needing To Add An Extra Page After A Group

Oct 26, 2007



I want to add an extra blank page after my group, anyone know how to do this? More specifically, I have a report that is grouped by State, when printing I want a blank page to appear before the start of a new State, this will help when the user prints duplex, etc.

View 9 Replies View Related

Needing To Run Reporting Services On SQL Server 2000

Nov 16, 2006

Hi
I want to install SQL Server 2000 Enterprise Edition on Windows XP but it isn't installing.
I have installed SQL Server 2000 Personal Edition but Reporting Services are not installing on the server.
PLZ some one help me out.

View 3 Replies View Related

Needing To Restore Msdb To Another Server To Save Dts And Jobs

Dec 3, 2007



I have a sql2000 server that has failed
i moved the databases to another server


I am trying to restore msdb to another server is this possible in order to get the dts packets and the jobs

View 5 Replies View Related

Long Running Transactions W/ Other Users Needing To Read Data

Jul 23, 2005

I have a very long transaction that runs on the same database thatother users need to use for existing data. I don't care if they seedata from the transaction before it is done and am only using thetransaction because I need a way to roll it back if any errors happenduring the transaction. Unfortunately all tables affected in the longrunning transaction are completely locked and nobody else can accessany of the affected tables while it is running. I am using thetransaction isolation level of read uncommitted, which from my limitedunderstanding of isolation levels is the least strict. What can I do toprevent this from happening?Below is the output from sp_who2 and sp_lock while the process isrunning and another process is being blocked by it.SPID Status LoginHostName BlkBy DBName Command CPUTimeDiskIO LastBatch ProgramName SPID----- ------------------------------------------------------------------------------ ---------- ----------------- ---------------- ------- ------ ------------------------------------------ -----1 BACKGROUND sa. . NULL LAZY WRITER 0 006/09 15:42:52 12 sleeping sa. . NULL LOG WRITER 10 006/09 15:42:52 23 BACKGROUND sa. . master SIGNAL HANDLER 0 006/09 15:42:52 34 BACKGROUND sa. . NULL LOCK MONITOR 0 006/09 15:42:52 45 BACKGROUND sa. . master TASK MANAGER 0 506/09 15:42:52 56 BACKGROUND sa. . master TASK MANAGER 0 006/09 15:42:52 67 sleeping sa. . NULL CHECKPOINT SLEEP 0 1206/09 15:42:52 78 BACKGROUND sa. . master TASK MANAGER 0 206/09 15:42:52 89 BACKGROUND sa. . master TASK MANAGER 0 006/09 15:42:52 910 BACKGROUND sa. . master TASK MANAGER 0 006/09 15:42:52 1011 BACKGROUND sa. . master TASK MANAGER 0 106/09 15:42:52 1112 BACKGROUND sa. . master TASK MANAGER 0 006/09 15:42:52 1251 sleeping SUPERPABLOAdministratorSUPERPABLO . PM AWAITING COMMAND 1813307 06/09 16:10:34 .Net SqlClient Data Provider 5152 sleeping SUPERPABLOAdministratorSUPERPABLO 54 PM SELECT 30 506/09 16:10:16 .Net SqlClient Data Provider 5253 RUNNABLE SUPERPABLOAdministratorSUPERPABLO . master SELECT 0 306/09 16:09:44 SQL Profiler 5354 RUNNABLE SUPERPABLOAdministratorSUPERPABLO . PM UPDATE 10095206 06/09 16:10:02 .Net SqlClient Data Provider 5456 RUNNABLE SUPERPABLOAdministratorSUPERPABLO . PM SELECT INTO 151 2706/09 16:10:33 SQL Query Analyzer 56(17 row(s) affected)spid dbid ObjId IndId Type Resource Mode Status------ ------ ----------- ------ ---- ---------------- -------- ------51 5 0 0 DB S GRANT52 5 0 0 DB S GRANT52 5 1117963059 4 PAG 1:7401 IS GRANT52 5 1117963059 4 KEY (5301214e6d62) S WAIT52 5 1117963059 0 TAB IS GRANT54 5 1117963059 0 TAB IX GRANT54 5 1852025829 0 TAB IX GRANT54 5 1181963287 3 PAG 1:9017 IX GRANT54 5 1117963059 4 KEY (5301934930a4) X GRANT54 5 1117963059 3 KEY (530187fc93f3) X GRANT54 5 1117963059 4 KEY (530154df71eb) X GRANT54 5 0 0 DB [BULK-OP-LOG] NULL GRANT54 5 0 0 FIL 2:0:d U GRANT54 5 1117963059 2 KEY (1d0096c50a7d) X GRANT54 5 1117963059 2 KEY (1b004a9a6158) X GRANT54 5 1117963059 2 KEY (1800a435d44a) X GRANT54 5 1181963287 6 PAG 1:8745 IX GRANT54 5 1181963287 4 PAG 1:8923 IX GRANT54 5 1181963287 2 PAG 1:8937 IX GRANT54 5 1117963059 4 KEY (5301112b0696) X GRANT54 5 0 0 PAG 1:10889 IX GRANT54 5 1181963287 5 PAG 1:8859 IX GRANT54 5 1181963287 6 PAG 1:10888 IX GRANT54 5 0 0 PAG 1:10891 IX GRANT54 5 0 0 PAG 1:10893 IX GRANT54 5 0 0 PAG 1:10892 IX GRANT54 5 0 0 PAG 1:10894 IX GRANT54 5 0 0 PAG 1:10882 IX GRANT54 5 1117963059 3 KEY (530135fbce35) X GRANT54 5 1117963059 0 RID 1:7387:57 X GRANT54 5 1117963059 0 RID 1:7387:59 X GRANT54 5 1117963059 0 RID 1:7387:61 X GRANT54 5 1117963059 3 KEY (5301406ad2bc) X GRANT54 5 1117963059 4 PAG 1:7401 IX GRANT54 5 0 0 PAG 1:7387 IX GRANT54 5 1117963059 2 PAG 1:7389 IX GRANT54 5 1117963059 3 PAG 1:7391 IX GRANT54 5 1117963059 0 RID 1:7387:10 X GRANT54 5 1117963059 0 RID 1:7387:56 X GRANT54 5 1117963059 0 RID 1:7387:58 X GRANT54 5 1117963059 0 RID 1:7387:60 X GRANT54 5 1117963059 3 KEY (530144afbed8) X GRANT54 5 1117963059 4 KEY (530115ee6af2) X GRANT54 5 1117963059 3 KEY (5301c6cd88ea) X GRANT54 5 1149963173 0 TAB IX GRANT54 5 1181963287 0 TAB X GRANT54 5 1117963059 4 KEY (5301d2782bbd) X GRANT54 5 1117963059 3 KEY (5301015bc9a5) X GRANT54 5 0 0 DB S GRANT54 5 0 0 DB [BULK-OP-DB] NULL GRANT54 5 1117963059 4 KEY (5301501a1d8f) X GRANT54 5 1117963059 2 KEY (1c00f3a2b6c5) X GRANT54 5 1117963059 2 KEY (1a002ffddde0) X GRANT54 5 0 0 PAG 1:7411 IX GRANT54 5 1117963059 2 KEY (1900c15268f2) X GRANT54 5 0 0 PAG 1:10840 IX GRANT54 5 1181963287 4 PAG 1:10841 IX GRANT54 5 0 0 PAG 1:10842 IX GRANT54 5 1117963059 3 KEY (5301059ea5c1) X GRANT54 5 0 0 PAG 1:10820 IX GRANT54 5 1181963287 4 PAG 1:10821 IX GRANT54 5 1181963287 5 PAG 1:10874 IX GRANT54 5 1181963287 5 PAG 1:10876 IX GRANT54 5 0 0 PAG 1:10877 IX GRANT54 5 1181963287 5 PAG 1:10878 IX GRANT54 5 0 0 PAG 1:10849 IX GRANT54 5 0 0 PAG 1:10850 IX GRANT54 5 1117963059 2 KEY (1700f225b712) X GRANT54 5 1117963059 4 KEY (5301214e6d62) X GRANT56 5 0 0 DB S GRANT56 1 85575343 0 TAB IS GRANT

View 29 Replies View Related

Newbie Here With A Newbie Error - Getting Database ... Already Exists.

Feb 24, 2007

Hi there
I sorry if I have placed this query in the wrong place.
I'm getting to grips with ASP.net 2, slowly but surely! 
When i try to access my site which uses a Sql Server 2005 express DB i am receiving the following error:

Server Error in '/jarebu/site1' Application.


Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.Source Error:



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:



[SqlException (0x80131904): Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.
Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735075
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
 
 This is the connection string that I am using:
 <connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;Initial Catalog=ASPNETDB;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
 
The database is definitly in the folder that the error message relates to.
What I'm finding confusing is that the connection string seems to be finding "aranga"s database.
Is it something daft?
 
Many thanks.
James 

View 1 Replies View Related

Inserting Distinct Data From One Table In Another Table, How?!?Really Urgent And Needing Help!!!

May 24, 2007

 Hi, I have a table in which I will insert several redundant data. Don't ask why, is Integration services, it only reads data and inserts it in a SQL table. THis way, I have a SQL table with several lines repeating them selves. What I want to do is create a procedure that reads the distinct data and inserts it in another table, but my problem is that I am not able to select data line by line on the original table to save it in local variables and insert it on the another table, I just can select the last line. I've tried a while cycle but no succeed. Here is my code: create proc insertLocalizationASdeclare @idAp int, @macAp varchar(20), @floorAp varchar(2), @building varchar(30), @department varchar(30)select @idAp = idAp from OLTPLocalization where idAp not in (select idAp from dimLocalization)select @macAp=macAp,@floorAp=floorAp,@building=building,@department=department from OLTPLocalizationif (@idAp <> null)beginInsert into dimLocalization VALUES(@idAp,@macAp,@floorAp,@building,@department)endGO This only inserts the last line in the "oltpLocalization" table. O the other hand, like this:create proc aaaaasdeclare @idAp as int, @macAp as varchar(50), @floorAp as int, @building as varchar(50), @department as varchar(50)while exists (select distinct(idAp) from OLTPLocalization)begin    select @idAp =idAp from OLTPLocalization  where idAp not in (select idAp from dimLocalization)    select @macAp = macAp from OLTPLocalization where idAp = @idAp    select @building = building from OLTPLocalization where idAp = @idAp    select @department = department from OLTPLocalization where idAP = @idApif (@idAp <> null)begin    insert into dimLocalization values(@idAp,@macAp,@floorAp,@building,@department)endendgo this retrieves every distinct idAp in each increment on the while statement. The interess of the while is really selecting each different line in the OLTPLocalization table. I did not find any foreach or for each statement, is there any way to select distinct line by line in a sql table and save each column result in variables, to then insert them in another table? I've also thought about web service, that reads the distinct data from the oltpLocalization into a dataset, and then inserts this data into the dimLocalization table. Is there anything I can do?Any guess?Really needing a hand here!Thanks a lot!

View 1 Replies View Related

Subreports: Parameter Value Dropdown Shows Sum And Count Fields But Not The Actual Data Fields.

Jan 28, 2008


I have just started using SQL Server reporting services and am stuck with creating subreports.

I have a added a sub report to the main report. When I right click on the sub report, go to properties -> Parameters, and click on the dropdown for Parameter Value, I see all Sum and Count fields but not the data fields.

For example, In the dropdownlist for the Parameter value, I see Sum(Fields!TASK_ID.Value, "AppTest"), Count(Fields!TASK_NAME.Value, "CammpTest") but not Fields!TASK_NAME.Value, Fields!TASK_ID.Value which are the fields retrieved from the dataset assigned to the subreport.

When I manually change the parameter value to Fields!TASK_ID.Value, and try to preview the report, I get Error: Subreport could not be shown. I have no idea what the underlying issue is but am guessing that it's because the field - Fields!TASK_ID.Value is not in the dropdown but am trying to link the main report and sub report with this field.

Am I missing something here? Any help is appreciated.

Thanks,
Sirisha

View 3 Replies View Related

Creating A Table In SQL Server With Fields From Other Tables And Some Fields User Defined

Feb 20, 2008

How can I create a Table whose one field will be 'tableid INT IDENTITY(1,1)' and other fields will be the fields from the table "ashu".
can this be possible in SQL Server without explicitly writing the"ashu" table's fields name.

View 8 Replies View Related

Public Overridable ReadOnly Default Property Fields() As ADODB.Fields

Jan 26, 2008

sir

I have got this error message to establish connction with recordset vb .net, Can you please rectify this

Too many arguments to 'Public Overridable ReadOnly Default Property Fields() As ADODB.Fields'

my code like this


rs = New ADODB.Recordset

rs.Open("Select * from UserLogin where userid='" & txtUserName.Text & "'", gstrDB, DB.CursorTypeEnum.adOpenStatic)


If txtUserName.Text = rs.Fields.Append(userid) Then


MsgBox("OK", MsgBoxStyle.OKOnly, "Confirmation")

End If


thanks

View 1 Replies View Related

Update Fields With Searched First Date Record Fields

Jul 23, 2005

Hello !I'm trying to update one table field with another table searched firstdate record.getting some problem.If anyone have experience similar thing or have any idea about it,please guide.Sample case is given below.Thanks in adv.T.S.Negi--Sample caseDROP TABLE TEST1DROP TABLE TEST2CREATE TABLE TEST1(CUST_CD VARCHAR(10),BOOKING_DATE DATETIME,BOOKPHONE_NO VARCHAR(10))CREATE TABLE TEST2(CUST_CD VARCHAR(10),ENTRY_DATE DATETIME,FIRSTPHONE_NO VARCHAR(10))DELETE FROM TEST1INSERT INTO TEST1 VALUES('C1',GETDATE()+5,'11111111')INSERT INTO TEST1 VALUES('C1',GETDATE()+10,'22222222')INSERT INTO TEST1 VALUES('C1',GETDATE()+15,'44444444')INSERT INTO TEST1 VALUES('C1',GETDATE()+16,'33333333')DELETE FROM TEST2INSERT INTO TEST2 VALUES('C1',GETDATE(),'')INSERT INTO TEST2 VALUES('C1',GETDATE()+2,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+11,'')INSERT INTO TEST2 VALUES('C1',GETDATE()+12,'')--SELECT * FROM TEST1--SELECT * FROM TEST2/*Sample dataTEST1CUST_CD BOOKING_DATE BOOKPHONE_NOC12005-04-08 21:46:47.78011111111C12005-04-13 21:46:47.78022222222C12005-04-18 21:46:47.78044444444C12005-04-19 21:46:47.78033333333TEST2CUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.800C12005-04-05 21:46:47.800C12005-04-14 21:46:47.800C12005-04-15 21:46:47.800DESIRED RESULTCUST_CD ENTRY_DATE FIRSTPHONE_NOC12005-04-03 21:46:47.80011111111C12005-04-05 21:46:47.80011111111C12005-04-14 21:46:47.80044444444C12005-04-15 21:46:47.80044444444*/

View 3 Replies View Related

Transact SQL :: Get One Row From Multiple Based On Fields And Also Get Sum Of Decimal Fields?

Jul 2, 2015

I am using MS SQL 2012.  I have a table that contains all the data that I need, but I need to summarize the data and also add up decimal fields while at it.  Then I need a total of those added decimal fields. My data is like this:

I have Providers, a unique ID that Providers will have multiples of, and then decimal fields. Here are my fields:

ID, provider_name, uniq_id, total_spent, total_earned

Here is sample data:

1, Harbor, A07B8, 500.00, 1200.00
2, Harbor, A07B8, 400.00, 800.00
3, Harbor, B01C8, 600.00, 700.00
4, Harbor, B01C8, 300.00, 1100,00
5, LifeLine, L01D8, 700.00, 1300.00
6, LifeLine, L01D8, 200.00, 800.00

I need the results to be just 3 lines:

Harbor, A07B8, 900.00, 2000.00
Harbor, B01C8, 900.00, 1800.00
LifeLine, L01D8, 900.00, 2100.00

But then I would need the totals for the Provider, so:

Harbor, 1800.00, 3800.00

View 3 Replies View Related

Search Multipe Fields, Compounding Fields, Like, Contains...?

Jul 20, 2005

I would like to search a table for a phrase, or for a partial phrase,eg on table product - for name or description, or name + descprition.How does one say select * from product where name + description like%phrase%or contains phraseCurrently I can get where name, or where descriotion like %phrase%,eg, where name like krups, or where description like coffee makerBut if I search for where name like %krups coffee maker% i get noresults. krups is in the name field, coffee maker is in thedescription field.Thanks,-M

View 1 Replies View Related

Update Fields With Data From Other Fields In Same Row

Jun 30, 2000

Pardon me if this question is too elementary. I am trying to create a trigger that will cause certain datafields to be updated with values from other data fields in the same row when a certain column, created specifically to fire the trigger, is updated. The purpose of this is to reduce data entry by field personnel.I think I have the create trigger statement correct, but I'm a little confused on the update statement.

In a nutshell, how can I write something like:
UPDATE "TABLENAME"
SET DATAFIELD1 = DATAFIELD2
WHERE RECORDNUMBER = (THE SAME RECORD NUMBER)

I do know that I have to ensure that sp_dboption Recursive Triggers value is set to false, thanks.

View 2 Replies View Related

Using LIKE To Find Any Of Fields In One Table In Fields Of Another

Jul 31, 2013

I have a list of items in one table and a field (pageName) in another table that may contain one of the aforementioned items somewhere within that field. There is no fixed position within the field where the itemNo may be so I can't just use SUBSTRING(pageName,2,5) in(select itemNo from tblItem).

Logically, it's like I need to combine IN and LIKE: select pageName where pageName LIKE IN %select itemNo from tblitemNo%..LIKE can only handle one comparison string.

View 5 Replies View Related

Drillthrough In Calculated Fields Enable When Drillthrough Option Is Disable In Original Fields, Is This A BUG?

Jan 21, 2008

Hi people
My users are having troubles with link to default drillthrough report when reports are exported to excel (they REALLY don't like this behavior ), so I decided set all of them disabled in report model, this work fine, but calculated field in reports has this drillthrough link.


Let me show you the situation. Entity Product has an UnitaryCost field, I set the EnableDrillthrough Property in False so when I export a report with this field, no link is shown.

But if I create in the report a calculated field Round(UnitaryCost) this field has a Drillthrough Link

Is this the standard and expected behavior? or its simply a BUG?

Have I done something wrong in my model? and in this case, How I can correct this?

regards.
Julio Diaz.

View 1 Replies View Related

Help In Joining

Jan 3, 2008

I want to make some joining in my table but I dont know what kind of joining is appropriate. Here is my tables sample:table1 -> tableid, useridtable2 -> userid, firstname, lastnametable3 -> userid, firstname, lastname Now, I want to to get data from table1 with the data from table2 and table3 where userid of table1 = table2, table3. 

View 2 Replies View Related

Joining From Two Different DB

Apr 17, 2006

May I know how to issue JOIN statement to join two ID from different DB ?
example:
dbA - tableA - a.ID
dbB- tableB - b.ID
Thanks.

View 2 Replies View Related

Joining 2 Tables...

Apr 29, 2007

Hi. I'm new to SQL, and need to join 2 tables... any hints???
 table1:id (int)title(varchar(50))body(text)
 table2:id (int)title(varchar(50))body(text)
somehow need to get the id, which table the record is from, and the title and body... so if the tables had the information:
table1:id          title                       body1           "first title"              "first body"2           "second title"         "second body"3           "third title"             "third body"
table2:id          title                       body1           "first title"              "first body"2           "second title"         "second body"3           "third title"             "third body"
 I would like to get...
id    table         title                     body3      1         "third title"             "third body"3      2         "third title"             "third body"2      1         "second title"         "second body"2      2         "second title"         "second body"1      1         "first title"              "first body"1      2         "first title"              "first body"
 Does anyone know how to get this? I am fairly flexible if i need to change things...
 cheers, eh!

View 1 Replies View Related

Inner Joining Two Tables

Aug 30, 2007

Hello everyone,I'm starting a new project right now and am trying to cut down on the number of stored procedures and tables I'm gonna have to use and I have run into a dead end.Up till now I have been doing the following: Say I had a PRODUCTS table with a DesignId column and ColorId column. I would then create a DESIGN table (Name, Id) and a COLOR table (Name, Id) to INNER JOIN with the two columns in my PRODUCTS table. And the same goes for all my other tables: ORDERS, CUSTOMERS, LINKS etc...... And in the end I would have a lot of tables and stored procedures for these category columns. So I thought, it would be nice to just have a Categories and Subcategories table for all my category columns for the whole website. That way every time I need to define a category column for any table I can simply just add the values to my Categories and Subcategories table instead of having to create a new table for every category column. Everything is fine and dandy except for trying to INNER JOIN these two tables with more than one column. To get values for one column is no problem:<code> SELECT     *,    _SubCategories.SubCategoryNameFROM     _ProductsINNER JOIN     _SubCategoriesON    _Products.DesignId = _SubCategories.SubCategoryIdWHERE    DesignId = COALESCE (@DesignId, DesignId)</code> But how do you INNER JOIN the ColorId column as well. Both DesignId and ColorId values are in my _SubCategories table. In a stored procedure: Is there any way to create a table and columns. Run a loop statement, with one INNER JOIN . Rerun another loop statement with a new INNER JOIN statement? Would that work or does any one else have an idea what would?Thank you guys for the help. It is much appreciated. Alec 

View 11 Replies View Related

Joining Two Tables In .NET??

Jan 14, 2008

Hello all,
I have two datatables "customersReached " and "customersGuessed " and I want to combine them into one table only, the problem is that one table exeeded to the other by two fields, so what can I do???????
Mahmoudona

View 4 Replies View Related







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