Can This Sub Query Code Can Be Done In Grouping
Feb 26, 2008
HI all, I got a tsql that needs to be simplified.
Select * from Table1 where condition1 and id not in
( Select id from table1 where condition2 and id in
( Select id from Table1 where condition1 )
)
basicly all records thats in condition1 but that doesnt have condition2 but limited to condition1. I'm probably maken this to complicated. but im tired and im losing time just on one stupid query. Thanks for the help.
View 9 Replies
ADVERTISEMENT
Nov 26, 2007
I'm really stumped on this one. I'm a self taught SQL guy, so there is probobly something I'm overlooking.
I'm trying to get information like this in to a report:
WO#
-WO Line #
--(Details)
--Work Order Line Detail #1
--Work Order Line Detail #2
--Work Order Line Detail #3
--Work Order Line Detail #etc
--(Parts)
--Work Order Line Parts #1
--Work Order Line Parts #2
--Work Order Line Detail #etc
WO#
-WO Line #
--(Details)
--Work Order Line Detail #1
--Work Order Line Detail #2
--Work Order Line Detail #3
--Work Order Line Detail #etc
--(Parts)
--Work Order Line Parts #1
--Work Order Line Parts #2
--Work Order Line Parts #etc
I'm unable to get the grouping right on this. Since the line details and line parts both are children of the line #, how do you do "parallel groups"?
There are 4 tables:
Work Order Header
Work Order Line
Work Order Line Details
Work Order Line Requisitions
The Header has a unique PK.
The Line uses the Header and a Line # as foreign keys that together are unique.
The Detail and requisition tables use the header and line #'s in addition to their own line number foreign keys. My queries ends up looking like this:
WO WOL WOLR WOLD
226952 10000 10000 10000
226952 10000 10000 20000
226952 10000 10000 30000
226952 10000 10000 40000
226952 10000 20000 10000
226952 10000 20000 20000
226952 10000 20000 30000
226952 10000 20000 40000
399999 10000 NULL 10000
375654 10000 10000 NULL
etc
Hierarchy:
WO > WOL > WOLD
WO > WOL > WOLR
It probobly isn't best practice, but I'm kinda new so I need some guidance. I'd really appreciate any help! Here's my query:
SELECT [Work Order Header].No_ AS WO_No, [Work Order Line].[Line No_] AS WOL_No,
[Work Order Requisition].[Line No_] AS WOLR_No, [Work Order Line Detail].[Line No_] AS WOLD_No
FROM [Work Order Header] LEFT OUTER JOIN
[Work Order Line] ON [Work Order Header].No_ = [Work Order Line].[Work Order No_] LEFT OUTER JOIN
[Work Order Line Detail] ON [Work Order Line].[Work Order No_] = [Work Order Line Detail].[Work Order No_] AND
[Work Order Line].[Line No_] = [Work Order Line Detail].[Work Order Line No_] LEFT OUTER JOIN
[Work Order Requisition] ON [Work Order Line].[Work Order No_] = [Work Order Requisition].[Work Order No_] AND
[Work Order Line].[Line No_] = [Work Order Requisition].[Work Order Line No_]
View 1 Replies
View Related
Jun 25, 2007
Hello everyone,
I've got an issue where I want to sum the group values and not the details, the reason is because I am hiding duplicate records. Here's how my Layout is setup.
TH
GH1 (hidden)
GH2 (hidden)
Det (hidden)
GF2 =Code.AddValue(Fields!Quantity.Value * Fieds!Cost.Value)
GF1 =Code.ShowAndResetSubTotal()
TF =Code.GrandTotal
I have the following in my Code window.
Dim Public SubTotal as Decimal
Dim Public GrandTotal as Decimal
Function ShowAndResetSubTotal() as Decimal
ShowAndResetSubTotal = SubTotal
SubTotal = 0
End Function
Function AddValue(newValue as decimal) as Decimal
SubTotal += newValue
GrandTotal += newValue
AddValue = newValue
End Function
This gives me incorrect results and I can't figure out why. Here's how it shows on my report:
Part Number
Quantity
Cost
Regular Subtotal Method
Using Custom Code
Part 1
4,000
1.49
$5,947.20
Customer 1
$11,894.40
$0.00
Part 2
10
1.01
$10.07
Customer 2
$50.34
$5,947.20
Part 3
1
0.44
$0.44
Part 4
6,050
0.25
$1,530.41
Part 5
0
1.25
$0.00
Part 6
0
1.23
$0.00
Customer 3
$42,851.86
$10.07
Part 7
16,250
0.24
$3,922.59
Customer 4
$19,612.94
$1,530.85
Part 8
17,250
0.38
$6,544.82
Part 9
27,225
0.20
$5,380.20
Customer 5
$66,891.69
$3,922.59
Grand Total
$141,301.23
$0.00
The issues brought up from the duplicates is shown in the "Regular Subtotal Method" column (there are 2 detail records for Customer 1-Part 1, which is why it is doubled). I can't use a distinct on the SQL query because there are other fields (not shown) on the report that are different.
As you can see, the GF1 (Customer #) shows the subtotal from the previous group, and the Table Footer (Grand Total) shows 0. Why is this?
Jarret
View 2 Replies
View Related
Oct 22, 2007
Hi,
I have this query...
cmd = New SqlCommand("SELECT name, webd_category_desc.category_id, (name + cast(webd_category_desc.category_id as nvarchar)) as CNameID, link_id FROM webd_category_desc left outer join webd_link_category on webd_category_desc.category_id = webd_link_category.category_id where display = 'True' order by CNameID, link_id ;", SqlConnection1)
It produces the following output (trunctated by me for this post example).
name
category_id
CNameID
link_id
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
7
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
22
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
24
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
40
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
45
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
89
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
134
Accounting/Bookkeeping
2
Accounting/Bookkeeping2
137
Architecture
5
Architecture5
37
Architecture
5
Architecture5
90
I would like it to display instead (where 8 and 2 are the counts):
Accounting/Bookkeeping 8
Architecture 2
Seeing that I had to join a few tables to get the above output, how can I now group on it to get the name, count(name) output I desire.I'm using ADO.NET in a VB.NET/ASP.NET 2.0 webapp. The data is in SQL Server 2000. I was hoping to do it in one SqlCommand statement if possible. I guess I can drop it into a view and then run my group by query on the view if I had to.
I am getting a variety of 'field in select list must be used in a function or aggregate' errors in the attempts I have tried so far.
Thanks in advance,
Stewart
View 6 Replies
View Related
Oct 29, 2007
Hi folks. Hopefully this is a simple question. What's the easiest and most efficient way to group by a dateTime field in an SQL query? Here is exactly what I'm trying to do. I have a database table that contains transactions from an email maillog, so there are dateTime entries every second or so. I'm trying to build a query that will group a count of messages per hour for a given day. How can I make an hourly grouping of the total number of messages?SELECT count(*)
FROM emailTable
WHERE (delivDate >= '2007-10-03 00:00' AND delivDate < '2007-10-03' 01:00)
Thanks, Chris
View 6 Replies
View Related
Jan 3, 2007
is grouping by sub query possible?
ie.
Code:
select
(select fieldx from tabley where pk = tz.fk) as field1,
field2
from
tablez tz
group by
field1
this doesn't work..i get an error that field1 is not valid...so is there a way to do this that does work?
please realize that the above example is exactly that..and had i needed to do something that easy, join would be the easy choice..what i'm trying to do requires a sub query
View 14 Replies
View Related
Jan 15, 2004
I have the following information in a table
ACCNORundateTRDCAPTRANQTYDLPRCE NOTEAMNT
27547920031202A-170002150000
27547920031202A-27412150000
27547920031202A-259215000-42501729
I need to create a query that totals TRANQTY and arrives at a result as in the following record.
ACCNORundateTRDCAPTRANQTYDLPRCE NOTEAMNT
27547920031202A-20000215000-42501729
and now for the $1M question...How ? I've tried the following select, but it is not working the way I want it to..
SELECT c2.ACCNO, c2.Rundate, c2.TrdCap, c2.TRANQTY, c2.DLPRCE, c2.NOTEAMNT
FROM CLIENTSHAREDEALS c2 FULL OUTER JOIN
(SELECT c1.ACCNO, c1.SHARENAME, SUM(c1.TRANQTY) AS Expr1
FROM CLIENTSHAREDEALS c1
WHERE (c1.ACCNO = '275479')
GROUP BY c1.ACCNO, c1.RUNDATE, c1.SHARENAME) c1 ON c1.ACCNO = c2.ACCNO AND c1.RUNDATE = c2.RUNDATE
WHERE (c2.ACCNO = '275479')
ORDER BY c1.RUNDATE
Thanks
View 2 Replies
View Related
Dec 5, 2005
I have a table with the following structure:main_category| category| sub_category| answer|dateBasically, the data will be along these lines:Neuro | LOC | Status | answer1|dateNeuro | LOC | Status | answer2|dateNeuro | LOC | Status | answer3|dateSenso| Visi | Clarity | answer1|dateSenso| Visi | Clarity | answer2|dateetc...I am trying to query the db and present the user with the data in thefollowing structure:Main CategoryCategorySub Categoryanswer1answer2answer3...Main CategoryCategoryEtc...There are literally 3 dozen main categories, categories, andsub-categories each with distinct answers.I could really use some help on a query to group the data in this way!Thanks in advance!!!Frank
View 4 Replies
View Related
Jun 13, 2004
I know this has been posted before, but I can't find the previous threads so please bear with me....
I want to grab the very 1st record of each product in a table like this
ID CLIENTID PRODID
1 a 1
2 b 1
3 c 1
4 a 2
5 b 2
6 c 2
7 a 3
8 b 3
9 c 3
so that I'd get a record set like:
ID CLIENTID PRODID
1 a 1
4 a 2
7 a 3
Thanks for the hellp guru's
View 4 Replies
View Related
Jan 5, 2005
Hello, everyone:
I have a table like:
Col1Col2
1A
2B
1D
1P
2F
2W
How to query this table to return by Col1 like
Col1Col2
1A,D,P
2B,F,W
Thanks a lot
ZYT
View 11 Replies
View Related
Aug 22, 2014
I have below data in one of my table:
Calls|Status
4|-6
12|-11
1|0
1|-10
Desired Output required :
Total_calls|Zero|Non-Zero
18|1|17
View 3 Replies
View Related
Nov 8, 2005
Hi,I have data stored as in below sample :-------------------------------+---------------------------------+--------------DateBegin | DateEnd | Rate-------------------------------+---------------------------------+--------------2005-11-13 00:00:002005-11-14 00:00:0063.00002005-11-14 00:00:002005-11-15 00:00:0063.00002005-11-15 00:00:002005-11-16 00:00:0045.00002005-11-16 00:00:002005-11-17 00:00:0045.00002005-11-17 00:00:002005-11-18 00:00:0045.00002005-11-18 00:00:002005-11-19 00:00:0045.00002005-11-19 00:00:002005-11-20 00:00:0045.00002005-11-20 00:00:002005-11-21 00:00:0063.00002005-11-21 00:00:002005-11-22 00:00:0063.0000-------------------------------+---------------------------------+--------------I have to group the select query in this way :-------------------------------+---------------------------------+--------------DateBegin | DateEnd | Rate-------------------------------+---------------------------------+--------------2005-11-13 00:00:002005-11-15 00:00:0063.00002005-11-15 00:00:002005-11-20 00:00:0045.00002005-11-20 00:00:002005-11-22 00:00:0063.0000-------------------------------+---------------------------------+--------------When I run below grouped statement, I get follewed result:SELECT MIN(DateBegin) AS DateBegin, MAX(DateEnd) AS DateEnd,Rate FROM X GROUP BY Rate-------------------------------+---------------------------------+--------------DateBegin | DateEnd | Rate-------------------------------+---------------------------------+--------------2005-11-13 00:00:002005-11-22 00:00:0063.00002005-11-15 00:00:002005-11-20 00:00:0045.0000-------------------------------+---------------------------------+--------------How can I do a query like in 2nd sample from top?best regards,rustam bogubaev
View 2 Replies
View Related
Jul 20, 2005
I'm having much difficulty figuring out how to write the followingquery. Please help!I have this table:EventEventId int Primary KeyPatientId intSeverityLevel intWhat I want returned in my query is a list of all (distinct)PatientIds appearing in Event, with the *most severe* EventId returnedfor each Patient. The higher the value of SeverityLevel, the moresevere that Event is considered to be.The problem I am having is that I can't figure out how to (a) group byPatientId, AND (b) return the EventId of the highest-severity Eventfor *each* PatientId (Order By SeverityLevel Desc).So if my table contained:EventId PatientId SeverityLevel------- --------- -------------1 1 02 1 13 1 54 2 55 2 2I would want my result set to be:PatientId EventId--------- -------1 32 4since events 3 and 4 are the most severe events for patients 1 and 2,respectively.Any help would be greatly appreciated. This seems to be something thatcould be handled easily with a FIRST() aggregate operator (as in MSAccess) but this is apparently lacking in SQL Server. Also note theremay be multiple Events with a given PatientId and SeverityLevel, inthat case I'd want only one of the EventIds (the Max() one).Many thanks,Joel ThorntonDeveloper, Total Living Choices<joelt@tlchoices.com>(206) 709-2801 x24
View 7 Replies
View Related
Apr 13, 2006
Hi,
How can I make a query and group the registries in a interval of 30 seconds...like
for each line I have a datetime field that have all the day, and I need it to return just like
TIME Contador_type1 Contador_type2 Total
01-01-2006 00:00:30.000 2 5 7
01-01-2006 00:01:00.000 3 7 10
It's just an example...but that's the result that I need and my table is
data_hora -- datetime field
tipo - 1 or 2 -- count
nrtelefone - that's is the number dialed.
Thanks
View 16 Replies
View Related
Dec 12, 2007
Hi,
Below is my DB Table..
Owner varchar(500)
contains...
OwnerA
OwnerB
Book varchar(500)
contains values...
Book1
Book2
Book3
Book1 might be owned by OwnerA
and Book2 might be owned by OwnerA and OwnerB
So in the Table is this...
ID Book Owner
1 Book1 OwnerA
2 Book2 OwnerA
3 Book2 OwnerB
How would I output this relationship in sql?
Thanks.
View 1 Replies
View Related
Jul 30, 2007
Hello,
I have a table similar to the following (XYZ). I would like to write a select statement that will return the count of the unique items for each user that also happen to be less than 1 year old. The less than one year old part is rather easy dateadd(year, -1, getdate()), but I seem to be having a hard time figuring out how to get my desired result without using subselects. Any help greatly appreciated. Thanks in advance - Dan.
So my goal results are:
User Count
Dan 2
Dave 1
Table XYZ
ID User Item Value Date
1 Dan 1 20 5/5/2007
2 Dan 1 30 6/5/2007
3 Dave 2 25 6/1/2007
4 Dan 2 22 5/1/2007
5 Dan 3 23 5/1/2006
View 6 Replies
View Related
Jul 29, 2015
I am trying to generate XML path from a SQL Server Table. Table Structure and sample data as belowÂ
CREATE TABLE #OfferTransaction
( [OfferLoanAmount1] INT
,[offferid1ProgramName] VARCHAR(100)
,[Offer1LenderName] VARCHAR(100)
,[offerid1LenderNMLSID] INT
[code]....
what changes do I need in my query so that the XML looks like the one above ( DESIRED XML). Is it possible via query changes?
View 3 Replies
View Related
Mar 13, 2012
I have a query where I have customers, date they ordered a swatch, date they ordered an item, and eh date diff between the two. I want to show the MIN date diff for each customer, and also show the swatch date and item date as well. But to use the MIN aggregate, it forces me to group everything, where I just want to group by customer, and have the 2 dates tag along, because i only want one record per customer. What is the easiest way for me to accomplish this?
SAMPLE:
CustKeySwatchDateRugDateDateDiff
10903963126678366
10903963126837525
10903963126960648
10913962286550322
1115886193625764
1129666456646711
1146986229625324
1146986229627647
11469862296667438
1146986656666711
1146986624666743
DESIRED RESULTS:
CustKeySwatchDateRugDateDateDiff
10903963126678366
1115886193625764
1129666456646711
1146986656666711
View 7 Replies
View Related
Mar 5, 2015
I have the query below which produces a succesful output but as there is more than one course date the month appears for example three times where there are three courses in Jan as the example output below how can I change the query to group these
MonthYear CCG AttendedCity CCG DNACity CCG Cancelled
Oct2014010
Jan2015000
Jan2015000
Jan2015100
Feb2015000
Mar2015210
May2015010
SQL QUERY
SELECT CONVERT(char(3), dbo.tblCourses.CourseDate, 0) AS Month, YEAR(dbo.tblCourses.CourseDate) AS Year, SUM(CASE WHEN a.AttendanceStatus IN (9)
THEN 1 ELSE 0 END) AS [City CCG Attended], SUM(CASE WHEN a.AttendanceStatus IN (3) THEN 1 ELSE 0 END) AS [City CCG DNA],
[Code] ....
View 2 Replies
View Related
May 22, 2008
I have a query that gets a supplier, a month, a year, status and sum of recpits.
returning the following. but my problem is I also need a col of totals. i tried to put a sub grouped query
in the select statement but keep getting an error
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
AR162600 ARROW ELECTRONICS 10424 Early 1 2008 2007-12-31 23:59:59.997
AR162600 ARROW ELECTRONICS 516 Late 1 2008 2007-12-31 23:59:59.997
AR162600 ARROW ELECTRONICS 279603 On-Time 1 2008 2007-12-31 23:59:59.997
my qurey is below. how can I get another col called total it will be the same value on each row.
AR162600 ARROW ELECTRONICS 10424 290543 Early 1 2008 2007-12-31 23:59:59.997
AR162600 ARROW ELECTRONICS 516 290543 Late 1 2008 2007-12-31 23:59:59.997
AR162600 ARROW ELECTRONICS 279603 290543 On-Time 1 2008 2007-12-31 23:59:59.997
SELECT ot_ven_num, ot_ven_name, sum(ot_rec_qty) as ot_rec_qty,
ot_rec_stat, datepart(Month,ot_rec_dt) as mth,
datepart(year,ot_rec_dt) as ryear,
DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(mm, 0, ot_rec_dt), 0)) as ot_rpt_date,
(SELECT ot_ven_num, ot_ven_name, sum(ot_rec_qty) as ot_rec_qty, 'Totals' as ot_rec_stat,
datepart(Month,ot_rec_dt) as mth,
datepart(year,ot_rec_dt) as ryear,
DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(mm, 0, ot_rec_dt), 0)) as ot_rpt_date
FROM supplierOT where ot_ven_name = 'ARROW ELECTRONICS' and datepart(year,ot_rec_dt) > 2007
group by ot_ven_num, ot_ven_name, DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(mm, 0, ot_rec_dt), 0)),
datepart(Month,ot_rec_dt),
datepart(year,ot_rec_dt)) as total
FROM supplierOT where ot_ven_name = 'ARROW ELECTRONICS' and datepart(year,ot_rec_dt) > 2007
group by ot_ven_num, ot_ven_name, ot_rec_stat, DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(mm, 0, ot_rec_dt), 0)),
datepart(Month,ot_rec_dt),
datepart(year,ot_rec_dt)
View 9 Replies
View Related
Oct 6, 2015
I have query on grouping data on weekly basis..
1. Week should start from Monday to Sunday
2. It should not consider current week data(suppose user clicks on report on Tuesday, it should display the data for last week).
3. I want output like below
Week1,week2,week3..... week12,AverageofWeek
12 , 10 ,0.........0 12
View 1 Replies
View Related
Nov 19, 2007
Dear All
I am a beginner and looking for some help. I have a database with just one column (some names). That is the primary key aswell. Because I want the names to be unique.I used a grid view control to display the data and included the insert functionality in the grid view by using some code and the part of the code that does the insert is 1 public static void Insert(Categories category)
2 {
3 string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
4 using (IDbConnection cn = new SqlConnection(connectionString))
5 {
6 cn.Open();
7
8 IDbCommand cmd = new SqlCommand();
9
10 cmd.CommandText = "INSERT INTO Categories (CategoryName) VALUES " +
11 "('" + category.CategoryName + "')";
12
13 cmd.Connection = cn;
14 cmd.ExecuteNonQuery();
15 }
16 }
Question: when someone tried to enter a new name which already exists in the database it throws an error page which is what I want but is there a way to be able to display the user a message sayin g that he/she has entered a name that already exists and hence they need to try a different name? instead of the ugly error page? Thank you in advance,Prasad.
View 7 Replies
View Related
Nov 17, 2003
Hi,
I need to bind to dropdown list, the conference names from the last one to the first one.
I'm using following query, the problem is it returns the conference names the number of dates created, since it's one table with all data I can't change it now.
Is there a way to get the names one time for each name without repeating?
string Sql = "SELECT DISTINCT conference_name,creation_date FROM Conference ORDER BY creation_date DESC";
SqlDataAdapter da = new SqlDataAdapter(Sql, myConn);
dataSet = new DataSet();
da.Fill(dataSet);
ddlConfName.DataTextField = "conference_name";
ddlConfName.DataSource = dataSet.Tables[0];
ddlConfName.DataBind();
View 2 Replies
View Related
Nov 16, 2006
Forgive me if i'm being really stupid but... we have an accounts package (Exchequer) using sql. I would like to use the tables in sql to interrogate the db further. However my numeric fields e.g. Credit Limit are split into 2 fields. One is a smallint type and one is an integer. How do I combine these fields to get an accurate value?
Thanks
View 4 Replies
View Related
Sep 12, 2007
I keep getting the error "Invalid attempt to read when no data is present" when trying to query a table in my SQL DB. I have checked and rechecked and the table name and column names within it are spelled correctly. There are only three records in the database, they all have data in them, and the code in Country.Text precisely matches the data in the Country field in one of the records.
It's worth mentioning that when I use Visual Studio 2005's little direct SQL query tool to build and run the following SQL statement that it works properly:
SELECT Country, WordForStateFROM data_CountriesWHERE (Country = N'Jordan')
I am perplexed. Any ideas anybody...here is the code...?
Dim SelectSQL_Countries As String
SelectSQL_Countries = "SELECT * FROM data_Countries "
SelectSQL_Countries &= "WHERE Country='" & Country.Text & "'"Dim con_Countries As New SqlConnection(ConfigurationManager.ConnectionStrings("MySiteMainDB").ConnectionString)
Dim cmd_Countries As New SqlCommand(SelectSQL_Countries, con_Countries)Dim reader_Countries As SqlDataReader
Try
con_Countries.Open()
reader_Countries = cmd_Countries.ExecuteReader()StateID.Text = reader_Countries("WordForState")
reader_Countries.Close()Catch err As Exception
lblResults.Text = err.Message
Finally
con_Countries.Close()
End Try
View 3 Replies
View Related
Nov 8, 2007
I have a database and would like to retrieve specific data via queries. This database is also connected to an ASP .Net 2.0 application to be the front end. Ive created the query in the database. Would you recommend i use parameter names to retrieve the data via code or should i have the query within my code to retrieve the data?
Thanks
View 6 Replies
View Related
Nov 27, 2005
Hey everyone,
I know this is a very simple problem however I've literally just begun learning about SQL and this is the first ever code i've created using the language.
The error is:
Msg 102, Level 15, State 1, Line 30
Incorrect syntax near ')'. Located on line containing "create table Trailer_Type"
create table Tralier
(load_types varchar(20),
Serial_no varchar(5),
constraint trailerkey primary key(Serial_no));
create table Tractor
(Reg_no varchar(8),
Descript varchar(20),
constraint tractorkey primary key(Reg_no));
create table Unit
(Unit_no varchar(4),
Total_length int(3),
Max_load int(2),
constraint unitkey primary key(Unit_no));
create table Maintenance
(Reg_no varchar(8),
Date_in date(8),
Date_out date(8),
Descript varchar(20),
Job_no varchar(6),
Mech_name varchar(20),
constraint maintenancekey primary key(Job_no));
create table Load_type
(load_type varchar(20),
constraint typekey primary key(load_type));
create table Trailer_Type
(constraint holds foreign key (serial_number) references
Trailer(serial_no),
Constraint holds foreign key (load_type)
references Load_type(load_type));
I'd be very greatful if someone could help me.
Thanks
David
View 6 Replies
View Related
May 15, 2007
Hi!
Can someone tell me how or where I can find information on editind an SQL query through code?
I want to be able to run a user-defined lookup, where the user can choose what the query will look for.
Thanks in advance.
Guy
View 5 Replies
View Related
Feb 7, 2008
Ok, so im pretty much finished writing my forum web page. However to display things like how many replies each thread has and who replied last, i need to perform a query in the code file. Im guessing its simple enough but i cant get the syntax for actually performing any query. I already know the sql syntax like select * from all that stuff but how do i get do something like:
Dim x as integer = sqlQuery("Select count(*) FROM ...")
Currently i have it all working by creating a table and making it invisible and just pulling data from the table but thats sloppy and pretty ineffecient if i databind a table for every single topic name.
View 9 Replies
View Related
Oct 10, 2006
When I want to user variable in the name of the database, I have an error. What's wrong with my code ?
DECLARE @BASE_SOURCE varchar (30),@BASE_DESTI varchar(30),@TEST varchar(30)
set @BASE_SOURCE='BASE1'
set @BASE_DESTI='BASE2'
select * from @BASE_SOURCE.dbo.FOURNISS
Msg*170, Niveau*15, État*1, Ligne*4
Ligne 4 : syntaxe incorrecte vers '.'.
View 2 Replies
View Related
Sep 27, 2013
I am writing a query now where I only want to get participants in the 112 service code only but this query I have is giving me other service codes as well when I have it set to 112. How can I fix this just so i can get this 112 service code only.
declare @bgDte smalldatetime
declare @enDte smalldatetime
declare @rgn char(2)
set @bgDte = '2013-01-01'
set @enDte = '2013-04-30'
set @rgn='05'
[Code] .....
View 3 Replies
View Related
Apr 2, 2008
Hi,
Is it possible to connect to a database and fetch data from it from within custom code inside a report?
Appreciate any help.
Regards,
Asim.
View 4 Replies
View Related
Feb 26, 2007
Hi,
I've created a stored procedure which inserts values into a table and upon successful execution the RC column gets returned along with the Identity value (I'm using SELECT SCOPE_IDENTITY()), but I don't want to RC column, I only want to get the Id number of the current row. I'm doing this using the Query Analyzer.
Is there a way to suppress the RC column? I have run the same query on different servers and the RC col doesn't show up. I only want the ID value to put into an ASP.NET page.
While testing different query methods from ASP.NET (Output parameter, Return_Value, etc) did I set a flag within SQL Server?
Sincerely,
Fred
View 1 Replies
View Related