Please Help Quick Statement Check
Apr 26, 2006
Hi, I was hoping someone could confirm the following about the
following number 2 SQL query:
1. This extracts the data required given that there is a recording to
match the records
2. This should, but im not convinced extract all the remaining records
that do not have a matched recording, but fulfil the rest of the
criteria. If not please help...
3. As the two querys produce the same layout of tables if I did a UNION
ALL, this should work shouldnt it?
Query 1:
------------
SELECT ai.entry_date as CallTime,
ai.agent_login as AgentsLogin,
ai.campaign as MarketingCampaign,
ai.agent_input2 as ProductsSold,
ai.first_name as Cust_FirstName,
ai.last_name as Cust_LastName,
ai.agent_input1 as Cust_PersonalNumber,
ai.street_address as Cust_AddressStreet,
ai.city as Cust_AddressCity,
ai.state as Cust_AddressState,
ai.zip as Cust_AddressZIP,
rec.file_name as AgreementRecordingFile
FROM agent_input ai,
leads l,
recordings rec
WHERE ai.whole_phone_number = l.whole_phone_number AND
l.call_status = 1110 AND
l.last_call_date between #04/24/2006 12:00 AM# and #04/25/2006
11:59 PM# AND
rec.whole_phone_number = l.whole_phone_number AND
rec.last_name = l.last_name AND
rec.agent = ai.agent_login AND
rec.campaign = l.campaign
ORDER BY ai.agent_login, ai.entry_date
Query 2.
-------------
SELECT ai.entry_date as CallTime,
ai.agent_login as AgentsLogin,
ai.campaign as MarketingCampaign,
ai.agent_input2 as ProductsSold,
ai.first_name as Cust_FirstName,
ai.last_name as Cust_LastName,
ai.agent_input1 as Cust_PersonalNumber,
ai.street_address as Cust_AddressStreet,
ai.city as Cust_AddressCity,
ai.state as Cust_AddressState,
ai.zip as Cust_AddressZIP,
'' as AgreementRecordingFile
FROM agent_input ai,
leads l,
recordings rec
WHERE ai.whole_phone_number = l.whole_phone_number AND
l.call_status = 1110 AND
l.last_call_date between #04/24/2006 12:00 AM# and #04/25/2006
11:59 PM# AND
count
(
SELECT rec.*
WHERE rec.whole_phone_number = l.whole_phone_number AND
rec.last_name = l.last_name AND
rec.agent = ai.agent_login AND
rec.campaign = l.campaign
) < 1
ORDER BY ai.agent_login, ai.entry_date
Thanks in advance for any help, its greatly appreciated.
David
View 4 Replies
ADVERTISEMENT
Mar 20, 2007
I am using SQL Server Express and ASP.I have a table that contains news articles, headlines, start and enddates. I am trying to create a recordset that shows all of thearticles that are greater than or equal to the start date and lessthan or equal to the end date. For some reason I cannot get it tofunction properly using a statement similar to StartDate >= Now() ANDEndDate <= Now(). SQL doesnt like the Now() piece of the statement.Anyone have an idea how I can get this to work? I have also triedCURDATE() but to no avail.Please help.
View 3 Replies
View Related
Nov 9, 2006
hi all
another easy one
how would i write it to where i select a value = 0 where all are equal to 0 rather than one line. when selecting based off a key from another table how would i select the values that all bring back 0 for that key rather than just a line or 2? i hope that makes sense, lol.
View 5 Replies
View Related
Sep 14, 2006
hi...
is there a statement to display the what recovery model on the database instead using GUI. Thanks~~~
View 2 Replies
View Related
Mar 6, 2008
greetings
Sir i want to check and use the select statement to select which field have a nullable=false in a table
View 1 Replies
View Related
Jun 19, 2002
I have to deal with an environment where the developers create and modify tables at will, and the tool they use does not check if the table created is over the 8060 limit for a table. I have a sql statement below which checks the size for me, but I can't figure out how to put a where clause on it to check for the size being over 8060. I i have over 1000 tables to check and was going to write a cursor routine to check it and print it, but I need te where clause to work.Any help appreciated
select Name=left(c.name,20),
c.prec, scale = ISNULL(c.scale,0),
t.name from syscolumns c inner join systypes
t on c.xtype = t.xtype where id in
(select id from sysobjects where name = 'mh_demographic2_')
order by c.colid COMPUTE sum(c.prec)
View 1 Replies
View Related
Jan 8, 2008
Hi, I am new to MS SQL Server; as I know Access, MYSQL. I made a form though which I want to insert data to SQL SERVER 2005 Database but i during submission I get the below problem, can any one help.
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]The INSERT statement conflicted with the CHECK constraint "SSMA_CC$Bcast$msgHTML$disallow_zero_length". The conflict occurred in database "x485i", table "dbo.Bcast", column 'msgHTML'.
/html/n_.asp, line 193
Best Regards,
Imran
View 3 Replies
View Related
Feb 26, 2008
Hello experts!
I have a case statement that provides filtering of hours during certain days of the week. An example is the data I want to show on Sunday is different from the rest of the week. I am using....
Code Snippet
WHERE ((CASE WHEN Datepart(dw, TestDateTime) = 1 AND datepart(hh, TestDateTime) BETWEEN 8 AND 22 THEN 1 WHEN Datepart(dw, TestDateTime)
>= 2 AND datepart(hh, TestDateTime) BETWEEN 6 AND 23 OR
datepart(hh, TestDateTime) BETWEEN 0 AND 2 THEN 1 ELSE 0 END) >= @ShowCore)
Esentially it gives a parameter (@showcore) to where it shows the filtered hours when 1 is selected, and all hours if 0 is selected.
Basically, Sunday I want to show transaction from between 8am and 10pm, All other days would be 12am - 2am and 6am to 11:59:59 when selecting 1 as the parameter.
Any help is appreciated.
View 3 Replies
View Related
May 5, 2008
What is the T-SQL command to check for NULL or '' in a field in one statement? I would like to change the following code to be more readable (without the OR).
IF @agent IS NULL OR @agent = ''
Thanks!
View 1 Replies
View Related
Feb 14, 2000
Hello all,
I am trying to add columns to several tables in a singular database. I want to check to see if the column exists in a given table first before executing the alter table command so that I can skip that command if the column already exists, and avoid aborting my script prematurely. I can't seem to find a way to check for the column's existance. Any suggestions?
View 2 Replies
View Related
Jan 9, 2015
My example data as this:
ID code1 code2
1 a m
1 b n
1 c T
2 d m
2 e n
2 f n
3 g m
3 h n
3 i T
I would like to have a select stmt that check for all same ID and code2 does not contain T, then return the records
For example data: the query should return
2 d m
2 e n
2 f n
Is it possible to do this?
View 9 Replies
View Related
Apr 8, 2008
Hi all,While using ACCESS and asp for years, I have just had to move my site onto a new server and the opportunity to move my 50MB access DB to msSQL was too good an opportunity to pass up! I used the Migration tools from MS and the data migrated nicely, I can do everything that I used to be able to do on the forum, except when a new user signs up or a member tries to edit their profile, the following error message comes up:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]The UPDATE statement conflicted with the CHECK constraint "SSMA_CC$PORTAL_MEMBERS$M_ICQ$disallow_zero_length". The conflict occurred in database "DATABASENAME", table "dbo.PORTAL_MEMBERS", column 'M_ICQ'.
I have checked the database and the dbo.PORTAL_MEMBERS table and except for the autoincrement number, uname and pwrd, everything else is set to accept nulls.
I also went though and filled in everything on the form then I could update.
the same error applies when signing up - the only difference is the name of the table
I then tried to change the data straight in the table by opening it in Server Management Studio Express and got the same error if I did not fill in everything. This tells me that it is not the code, much to my relief!
So I am figuring that there is something somewhere in the DB that I have to change? could someone point me in the right direction - and as I am VERY NEW to this database system, and do not know my way around (it took me about 10 minutes to figure out how to open a table! *LOL*) very clear instructions would be appreciated.
Thank you for your time :-)
View 14 Replies
View Related
May 20, 2015
I have multiple ODBC connection and how to check all connection automatically during routine check by using batch file.
View 5 Replies
View Related
May 13, 2008
I have to implement some logic in a view and I don't know how to do it. Let me outline the logic:
- I'm working with a view where records represent participant activities.
- Some participants can have numerous activities.
- Each activity has a start date and an activity code.
- Only records with activity code 23 or 33 appear in the view currently.
What I need to do is NOT include records where the participant has another activity with code 26 (from another table, the one the current view is derived from) which has the same start date as the activity 23/33 record in the view currently. Also, this should only be implemented if the start date is the first start date (minimum start date for that participant).
Little help?
View 9 Replies
View Related
Mar 15, 2007
I've noticed that there are a lot of questions on this forum, but not as many thank you's. I'm far from a DBA (more of a simple, small town, one stop shop), but have learned tons of information from reading your posts. I certainly appreciate everyone's willingness and excitment to contribute to the SQL community. So here's to you...thank you!
Erik
View 1 Replies
View Related
Jul 24, 2007
hey guys, how could you get the primary key field of a record you have just inserted into a table?
Many thanks
View 6 Replies
View Related
Jul 31, 2007
Hey guys,
How would you copy data between two identical tables residing on two different databases?
So we have table1 on database1 and table2 on database2. I would like to copy the entire contents from table1 to table2.
Muchos gracias
View 1 Replies
View Related
Aug 10, 2007
Hi All
What am i doing wrong with this im tired and for the life of me it wont work
Cheers
Phil
if
(Select sum(Unitprice*qtysold) from #DataExport_tmp where recordtype = 'L'group by transref )<> select Totalcost from #DataExport_tmp where recordtype = 'T'
BEGIN
PRINT 'no good'
end
View 3 Replies
View Related
Oct 28, 2007
i use windows vista and installed visual net 2005 and sqlserver 2005
but i have some proplem:
my step:
1.open vs net 2005
2.make one project
3.make one button
4.get data->datagridview
5.choose add data source
6.choose new data---> this step then choose microsoft sql server
7.typing servername
8.choose attach a database file and choose browe..
9.link to folder have database(.dbf)
but i have worked them very much but not run for me
i dont know why it is like that
"login faild"or you dont have permission to pen this filecontact the file ower or an administrator to obtain permissio
pls help me i very need for learning
my Y!M: phok28a@yahoo.com
pls contact me and help me
View 1 Replies
View Related
Dec 15, 2006
What is the parameters for starting & stoping sqlserver 2005 from start/run or from the command prompti tried 'sqlservr' & it didn't work
View 1 Replies
View Related
Nov 11, 2007
Hey guys... i cant figure this out for the life of me. I have a long T-sql query, and when i enter the string "Rental" into the Listingtype, it says invalid column name "Rental" ... im not looking for the value to be a column, im looking for it to match the value in the ListingType column... here's the query:
(
@StudioINT = NULL,
@Br1INT = NULL,
@Br2INT = NULL,
@Br3INT = NULL,
@Br4INT = NULL,
@OverBr4INT = NULL,
@CondoINT = NULL,
@ListingTypevarchar(10) = NULL,
@WindowAirINT = NULL,
@CentralACINT = NULL,
@BalconyDeckPatioINT = NULL,
@UseOfYardINT = NULL,
@DishwasherINT = NULL,
@WasherDryerINT = NULL,
@FireplaceINT = NULL,
@EIKINT = NULL,
@HardwoodFloorsINT = NULL,
@BroadbandNetINT = NULL,
@TVINT = NULL,
@ThermostatINT = NULL,
@LandlordNotPresentINT = NULL,
@SmokingINT = NULL,
@NoPetsAllowedINT = NULL,
@CatINT = NULL,
@MoreCatsINT = NULL,
@SmallDogINT = NULL,
@LargeDogsINT = NULL,
@DoorpersonINT = NULL,
@IngroundPoolINT = NULL,
@AboveGroundPoolINT = NULL,
@ElevatorINT = NULL,
@UseOfGarageINT = NULL,
@LaundryFacilitiesINT = NULL,
@HealthCenterINT = NULL,
@StorageAreasINT = NULL,
@WheelchairAccessINT = NULL,
@BusinessCentersINT = NULL,
@RentChargeMinINT = NULL,
@RentChargeMaxINT = NULL,
@DebugBIT = 1
)
AS
SET NOCOUNT ON
DECLARE @SQL VARCHAR(8000)
SET @SQL = '
SELECT
r.REListingID,
r.REListingDate,
r.Username,
r.ZipCode,
r.ListingType,
r.StudioFlag,
r.BRFlag1,
r.BRFlag2,
r.BRFlag3,
r.BRFlag4,
r.OverBRFlag4,
r.CondoFlag,
a.WindowAir,
a.CentralAir,
a.BalconyDeckPatio,
a.UseOfYard,
a.Dishwasher,
a.WasherDryer,
a.Fireplace,
a.EIK,
a.HardwoodFloors,
a.BroadbandNet,
a.TV,
a.Thermostat,
a.LandlordNotPresent,
a.Smoking,
a.NoPetsAllowed,
a.Cat,
a.MoreCats,
a.SmallDog,
a.LargeDogs,
a.Doorperson,
a.IngroundPool,
a.AboveGroundPool,
a.Elevator,
a.UseOfGarage,
a.LaundryFacilities,
a.HealthCenter,
a.StorageAreas,
a.WheelchairAccess,
a.BusinessCenters,
a.RentCharge,
a.RentFrequency
FROMdb_REListings as r
INNER JOINdb_RentalAmenities AS a ON a.REListingID = r.REListingID
WHERE1 = 1
'
IF @Studio IS NOT NULL
SET @SQL = @SQL + ' AND r.StudioFlag = ' + CONVERT(VARCHAR(20), @Studio)
IF @Br1 IS NOT NULL
SET @SQL = @SQL + ' AND r.BRFlag1 = ' + CONVERT(VARCHAR(20), @Br1)
IF @Br2 IS NOT NULL
SET @SQL = @SQL + ' AND r.BRFlag2 = ' + CONVERT(VARCHAR(20), @Br2)
IF @Br3 IS NOT NULL
SET @SQL = @SQL + ' AND r.BRFlag3 = ' + CONVERT(VARCHAR(20), @Br3)
IF @Br4 IS NOT NULL
SET @SQL = @SQL + ' AND r.BRFlag4 = ' + CONVERT(VARCHAR(20), @Br4)
IF @OverBr4 IS NOT NULL
SET @SQL = @SQL + ' AND r.OverBRFlag4 = ' + CONVERT(VARCHAR(20), @OverBr4)
IF @Condo IS NOT NULL
SET @SQL = @SQL + ' AND r.CondoFlag = ' + CONVERT(VARCHAR(20), @Condo)
IF @ListingType IS NOT NULL
SET @SQL = @SQL + ' AND r.ListingType = ' + CONVERT(char, @ListingType)
IF @WindowAir IS NOT NULL
SET @SQL = @SQL + ' AND a.WindowAir = ' + CONVERT(VARCHAR(20), @WindowAir)
IF @CentralAC IS NOT NULL
SET @SQL = @SQL + ' AND a.CentralAir = ' + CONVERT(VARCHAR(20), @CentralAC)
IF @BalconyDeckPatio IS NOT NULL
SET @SQL = @SQL + ' AND a.BalconyDeckPatio = ' + CONVERT(VARCHAR(20), @BalconyDeckPatio)
IF @UseOfYard IS NOT NULL
SET @SQL = @SQL + ' AND a.UseOfYard = ' + CONVERT(VARCHAR(20), @UseOfYard)
IF @Dishwasher IS NOT NULL
SET @SQL = @SQL + ' AND a.Dishwasher = ' + CONVERT(VARCHAR(20), @Dishwasher)
IF @WasherDryer IS NOT NULL
SET @SQL = @SQL + ' AND a.WasherDryer = ' + CONVERT(VARCHAR(20), @WasherDryer)
IF @Fireplace IS NOT NULL
SET @SQL = @SQL + ' AND a.Fireplace = ' + CONVERT(VARCHAR(20), @Fireplace)
IF @EIK IS NOT NULL
SET @SQL = @SQL + ' AND a.EIK = ' + CONVERT(VARCHAR(20), @EIK)
IF @HardwoodFloors IS NOT NULL
SET @SQL = @SQL + ' AND a.HardwoodFloors = ' + CONVERT(VARCHAR(20), @HardwoodFloors)
IF @BroadBandNet IS NOT NULL
SET @SQL = @SQL + ' AND a.BroadbandNet = ' + CONVERT(VARCHAR(20), @BroadbandNet)
IF @TV IS NOT NULL
SET @SQL = @SQL + ' AND a.TV = ' + CONVERT(VARCHAR(20), @TV)
IF @Thermostat IS NOT NULL
SET @SQL = @SQL + ' AND a.Thermostat = ' + CONVERT(VARCHAR(20), @Thermostat)
IF @LandlordNotPresent IS NOT NULL
SET @SQL = @SQL + ' AND a.LandLordNotPresent = ' + CONVERT(VARCHAR(20), @LandLordNotPresent)
IF @Smoking IS NOT NULL
SET @SQL = @SQL + ' AND a.Smoking = ' + CONVERT(VARCHAR(20), @Smoking)
IF @NoPetsAllowed IS NOT NULL
SET @SQL = @SQL + ' AND a.NoPetsAllowed = ' + CONVERT(VARCHAR(20), @NoPetsAllowed)
IF @Cat IS NOT NULL
SET @SQL = @SQL + ' AND a.Cat = ' + CONVERT(VARCHAR(20), @Cat)
IF @MoreCats IS NOT NULL
SET @SQL = @SQL + ' AND a.MoreCats = ' + CONVERT(VARCHAR(20), @MoreCats)
IF @SmallDog IS NOT NULL
SET @SQL = @SQL + ' AND a.SmallDog = ' + CONVERT(VARCHAR(20), @SmallDog)
IF @LargeDogs IS NOT NULL
SET @SQL = @SQL + ' AND a.LargeDogs = ' + CONVERT(VARCHAR(20), @LargeDogs)
IF @Doorperson IS NOT NULL
SET @SQL = @SQL + ' AND a.Doorperson = ' + CONVERT(VARCHAR(20), @Doorperson)
IF @IngroundPool IS NOT NULL
SET @SQL = @SQL + ' AND a.IngroundPool = ' + CONVERT(VARCHAR(20), @IngroundPool)
IF @AboveGroundPool IS NOT NULL
SET @SQL = @SQL + ' AND a.AboveGroundPool = ' + CONVERT(VARCHAR(20), @AboveGroundPool)
IF @Elevator IS NOT NULL
SET @SQL = @SQL + ' AND a.Elevator = ' + CONVERT(VARCHAR(20), @Elevator)
IF @UseOfGarage IS NOT NULL
SET @SQL = @SQL + ' AND a.UseOfGarage = ' + CONVERT(VARCHAR(20), @UseOfGarage)
IF @LaundryFacilities IS NOT NULL
SET @SQL = @SQL + ' AND a.LaundryFacilities = ' + CONVERT(VARCHAR(20), @LaundryFacilities)
IF @HealthCenter IS NOT NULL
SET @SQL = @SQL + ' AND a.Health Center = ' + CONVERT(VARCHAR(20), @HealthCenter)
IF @StorageAreas IS NOT NULL
SET @SQL = @SQL + ' AND a.StorageAreas = ' + CONVERT(VARCHAR(20), @StorageAreas)
IF @WheelchairAccess IS NOT NULL
SET @SQL = @SQL + ' AND a.WheelchairAccess = ' + CONVERT(VARCHAR(20), @WheelchairAccess)
IF @BusinessCenters IS NOT NULL
SET @SQL = @SQL + ' AND a.BusinessCenters = ' + CONVERT(VARCHAR(20), @BusinessCenters)
IF @RentChargeMin IS NOT NULL AND @RentChargeMAX IS NOT NULL
SET @SQL = @SQL + ' AND a.RentCharge BETWEEN ' + CONVERT(VARCHAR(20), @RentChargeMin) + ' AND ' + CONVERT(VARCHAR(20), @RentChargeMax)
IF @RentChargeMin IS NOT NULL AND @RentChargeMAX IS NULL
SET @SQL = @SQL + ' AND a.RentCharge >= ' + CONVERT(VARCHAR(20), @RentChargeMin)
IF @RentChargeMAX IS NULL AND @RentChargeMAX IS NOT NULL
SET @SQL = @SQL + ' AND a.RentCharge <= ' + CONVERT(VARCHAR(20), @RentChargeMax)
IF @Debug = 1
PRINT @SQL
EXEC (@SQL)
View 5 Replies
View Related
Dec 7, 2007
this query works, i want to add a 4th column that is the value of the 3rd column subracted from the value of the 2nd column, how can i add this?? SELECT `tagid` AS w1, (SELECT count( `value` )FROM tagsWHERE `value` =1AND `tagid` = w1) AS w2, (SELECT count( `value` )FROM tagsWHERE `value` =0AND `tagid` = w1) AS w3FROM tagsWHERE `value` > -1GROUP BY `tagid`ORDER BY w2 DESC
View 1 Replies
View Related
Apr 6, 2004
Hey,
I know thsi is a silly question but gonna ask it anyway :)
When you are using the 'insert' statement to insert records in to a database are all of the fields in the db table required for a successfull adding of a record.
Just that i have 16 fields in my db table and want to insert only 11 fields in to the new record and it is giving me an error, and i am sure my SQL is correct
So are all fields required ?
Thankyou
Chris
View 2 Replies
View Related
Apr 25, 2001
I just need something verified.. This has to do with IP's and names. We have a sql failover cluster. So is that 4 names.. One for each local machine, one for the cluster itself and one for the sql portion? I guess my question is can the cluster group and sql have the same name and IP or do they need to be different.
Thanks in advanced.
View 1 Replies
View Related
Apr 20, 1999
Does any one know a quicker way to get data in from TableA to TableB.
Both tables have the same structure(Acct# varchar(9); Type varchar(12);
Date1 datetime; Date2 datetime; Date3 datetime; Date4 datetime; and Date5 datetime
No Nulls allow in Acct & Type field.
TableA has 5.5 Million Rows and TableB has about 1 million rows , I wrote a Stored Proc
using cursor to select from TableA insert into TableB if the Acct# and Type doesn't exists.
I didn't want to use bcp because I only wanted rows(Acct#'s) that exists in TableA that where not in
TableB. My procedure is working but at a rate of 100 records per minute. Any suggestions?
View 2 Replies
View Related
Jun 10, 2004
I have a client that's insisting on deploying SQL Server 2000 as Windows Authntication mode only (not mixed mode). I've always done mixed mode in the past and I'm just looking for some input here. So, what's everyone think?
View 4 Replies
View Related
Jun 17, 2004
do not have time to go through BOL .. but whats the command beside dbcc freeproccache to clear the cache .
View 1 Replies
View Related
Nov 2, 2006
try to guess what the result is for this query before you run it:SELECT 123.654, 123d6, 123e4, '123'e4comments welcome, but please do not spoil it for anyone who hasn't tried it yet
source: http://sqlservercode.blogspot.com/
View 4 Replies
View Related
Nov 14, 2005
For a query like below ...
How do i have to select only the latest revisions,
if i need to filter last current revisions of each document ...
where the revision could be either alphabetical or even numerical ...
Presently I get all revisions with the below query ...
Note: csd_revi is the field of CSD table for revisions.
---
select distinct
csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi as "Document Reference No.",
csd1.csd_labl + ' ' as "Description"
from
E0437csd csd1,
E0437tra tra1,
E0437csd csd2,
E0437trd trd1,
E0437apr apr1,
E0437apc apc1,
E0437tra tra2,
E0437csd csd3,
E0437trd trd2
where
csd1.csd_orig = 'BS' and
csd1.csd_subj like '%WN1%' and
csd1.csd_type = 'D' and
tra1.tra_drgn = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
tra1.tra_part = 'PARSO' and
tra1.tra_type = 'A' and
csd2.csd_orig + csd2.csd_subj + csd2.csd_type + csd2.csd_numb + csd2.csd_revi = tra1.tra_trno and
trd1.trd_trno = tra1.tra_trno and
trd1.trd_cc = '0' and
trd1.trd_part = 'PARSO' and
apr1.apr_docu = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
(apr1.apr_stat = apc1.apc_code or apr1.apr_stat = '') and
tra2.tra_drgn = csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi and
tra2.tra_part = csd1.csd_ownr and
csd3.csd_orig + csd3.csd_subj + csd3.csd_type + csd3.csd_numb + csd3.csd_revi = tra2.tra_trno and
trd2.trd_trno = tra2.tra_trno
order by
csd1.csd_orig + csd1.csd_subj + csd1.csd_type + csd1.csd_numb + csd1.csd_revi
---
Life is beautiful ... When you smile ...
View 3 Replies
View Related
Feb 22, 2006
I asked a question over the weekend and got a answer very quick. I'm new to stored procedures and have to do a insert into two tables. I need to insert into the first table (Journal_log). This table has a colunm ID that is Identity is set to yes. After inserting that record I need to retrieve the ID from the Journal_log that I just inserted and insert it into the second table (District_Journal) with data for a new record into the second. Can this be done in one stored procedure or do I have to have two?
View 20 Replies
View Related
Dec 28, 2006
Hi Everyone,
I'm new to the board and somewhat new to sql too. So I have a small problem that I hope someone can help me with.
DATA
Name: time1 time2
Jack 1 2
Jack 2 3
Jack 3 4
Jack 8 9
Jane 3 4
I'd like to get a table that combines all the continuous times for each person so that it looks like this:
Jack 1 4
Jack 8 9
Jane 3 4
I'm desperate, and I appreciate it any help! Thanks!
View 5 Replies
View Related
Jan 23, 2007
If I have:
Table Test
TestID (PK)
PretestTech (FK IndividualID)
PostTestTech (FK IndividualID)
ProjectManager (FK IndividualID)
TestInfo
Table Individuals
IndividualID (PK)
Initials
First
Last
Is there an efficient way to query for a list of tests with the PretestTech,PostTestTech,and Project manager initials? I guess I'm stuck because I want to Join the Test and Individual tables but there are three fields that need to be joined. So this is the only way I can think to make it work:
SELECT
TestID
,TestInfo
,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.PretestTech) AS 'PretestTech Initials'
,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.PostTestTech) AS 'PostTestTech Initials'
,(SELECT Individual.Initials FROM Individual WHERE Individual.IndividualID = Test.ProjectManager) AS 'ProjectManager Initials'
FROM Test
Is this efficient or should I rethink my Table design?
Thanks
View 3 Replies
View Related
Apr 15, 2007
I can not for the life of me get a count to work in the following statement? Can i use count like this?
select right(replicate('0', 10) + (count(Recordtype)) ,10) from dataexport where Recordtype = 'T'
Thanks
View 5 Replies
View Related