What Is Expert SQL Knowledge?
Jul 23, 2005
I do a lot of hiring for my company and a lot of the people I interview
say that they are experts at SQL queries, but when I give them something
simple just beyond the typical SELECT type of queries, they choke.
For example I have a table that looks like this:
PK_ID - primary key
PARENT_ID - a FK to another row in the same table
This essentially is a tree structure. I will ask interviewees to write
a query that will return all the rows that have 2 direct children. No
one knows how to do this.
I don't get it. I have done queries which boggle the mind and they are
far more complex than this.
Am I asking too much?
--
* Don Vaillancourt
Director of Software Development
*
*WEB IMPACT INC.*
phone: 416-815-2000 ext. 245
fax: 416-815-2001
email: Join Bytes! <mailto:donv@webimpact.com>
web: http://www.web-impact.com
/ This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright. If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.
/
View 15 Replies
ADVERTISEMENT
Mar 13, 2008
I am loosing my mind on this one. I select info from a database. I then take that selected info, and select info from another table based on that. Straight forward. The CompanyKey attached to my username is 7 which displays in the ReaderResults.Text. I the following line:
selectSQL2 = "SELECT * FROM Company WHERE companyKey = ('" + CompanyKey + "')"
I can change it to:
selectSQL2 = "SELECT * FROM Company_Membership WHERE companyKey = 7 "
and it works. I have no idea what is going on. Dissapearing string? Here is the code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")
'Job1 InfoDim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL1 As String
selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con)
Dim reader As SqlDataReaderDim CompanyKey
'Job2 Info
Dim selectSQL2 As String
selectSQL2 = "SELECT * FROM Company WHERE companyKey = ('" + CompanyKey + "')"Dim cmd2 As New SqlCommand(selectSQL2, con)
'Job1 Select
Try
con.Open()
reader = cmd1.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
Finally
ReaderResults.Text = CompanyKey
con.Close()
End Try
'Job2 Select
Try
con.Open()
reader = cmd2.ExecuteReader()
GridView1.DataSource = reader
GridView1.DataBind()
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
Finally
ReaderResults.Text = CompanyKey
con.Close()
End Try
View 7 Replies
View Related
Mar 31, 2004
Hi,
I need help to test person's skills for
knowledge of SQL stored procedures
and DTS
Could someone point on good resources.
Thank you
Alex
View 4 Replies
View Related
Jun 3, 2004
Hello, everyone:
Are ther any basic information about patch on SQL Server? How to develop patch, and run it? Thanks a lot
ZYT
View 7 Replies
View Related
Aug 29, 2006
Dear Friends, please tell me how can i gain domain knowledge in erp related modules?
View 3 Replies
View Related
Jul 22, 2007
Hello everyone...
i am new to Structured Query Language. I am learning it for the past 6 months form a book by myself. I don't have a teacher available to me. Now when i have finished that with all of the exercises completed. i want to make sure what i've learned is i've really learned it. the problem is that there is no such organization here that i join and have some hand on practical. So now i am asking u guys to help me. Tell me some way so that i make sure of whatever knowledge i have about SQL.
don't worry be happy
View 1 Replies
View Related
Jan 12, 2004
Yo!
My company asked me to do a tech interview on a potential contractor for a three month assignment writing SQL Server stored procedures.
I have some things I can ask him to test his qualifications, such as cross-tab query design, UDF usage, running total queries, select first 'N' queries, Primary Keys vs Clustered Indexes, etc...
I was curious what questions other people might ask in order to assess a person's skill. Remember that this is SQL programming only, not admin stuff, and I want to ask questions with a range of difficulty from easy to head-cracker.
Any suggestions?
View 14 Replies
View Related
Sep 24, 2007
I am having a puzzling problem with a DTS package in SQL 2000 that uses a combination of "Execute Process Tasks" and "ActiveX Script Tasks." The issue occurs with one of (the second) the ActiveX Script Task. The script invokes a COM object that was written in C#. This COM object connects to the database and writes a record set and then calls a stored procedure.
When I run this step individually, everything works fine. When I run it as part of the package, the record set is being written but the stored procedure is not invoked (SQL Profile confirms this).
I haven't really begun a serious attempt to troubleshoot the problem, though I have played around with the Transactions and OLE DB properties of the DTS Package.
Any suggestions as to why the behavior might be different, or some straightforward tips on troubleshooting would be appreciated. I have access to the COM component source.
View 1 Replies
View Related
Nov 21, 2006
I dont know where to put this thread, I just wanna ask a question..actually what is happen when subscription synchronized the publications among IIS process.. (SQLMobile)
could you guys give me a diagram/schema of it?
thanks before
View 6 Replies
View Related
Jun 12, 2006
I don't have any knowledge about SQL Server at all... I wanna know:
1. What is SQL Server?
2. Have SQL Server something to do with databases and Microsoft Access to do?
3. What is the link between Visual C++ Express Edition and SQL Server Express Edition?
4. Where on the web can I learn (tutorials) how to use SQL Server Express Edition?
View 3 Replies
View Related
Feb 26, 2007
Dear Friends,
please suggest me the best book to gain sound knowledge in DBA concepts as well as
writing in sub queries, complex queries as well as inner queries.
thank you very much
Vinod
View 4 Replies
View Related
Nov 26, 2007
Hi,
I've been working as a .NET developer for many years. However, my educational background isn't in IT at all, so I occasionally find that there are big gaps in my knowledge when I'm called on to do certain things.
My current role is the first one I've had where the efficiency of my database calls has needed to be top-notch. Most of my previous posts have been in building intranet functionality for medium-sized companies so it's just not been an issue and my fairly basic level of SQL knowledge has been enough to get me by.
However, I'm increasingly finding I'm needing to look stuff up, ask for help and so forth and I'm not at all sure that what I'm putting out is up to scratch. I have three main areas of concern:
1) The developers here seem to like doing a lot of the "work" of data sorting and manipulation in SQL whereas I'd previously have just grabbed the whole table and done the manipulation in .NET. I'm finding building my complex queries is just doing my head in - I'm just not used to "thinking" in the way that SQL requires which seems very different from procedural programming.
2) A lot gets said about properly indexing tables for maximum efficiency. I know what an index is and vaguely what it does, but the means of applying them to ensure the best performance is pretty much beyond me.
3) In the same manner I'm now having to worry a lot more about performance issues in my database design. I now the five normal forms and so on, but is there anything else here I need to do to maximise performance?
What I'm asking, really, is whether anyone can recommend a good source for SQL knowledge (book, site, whatever) that specifically focuses on my first problem - it'll teach me the proper way to structure my queries and think about them properly so that they don't look so damn impenetrable. It then needs to go on and address my other issues.
Any suggestions?
View 4 Replies
View Related
Jul 20, 2005
Greetings,I have to admit that I'm still a beginner in the database field, but I'mactively studying, and this is why I will be utterly grateful for theproper, accurate, and wise guidance to the right direction or specificpaths of database studies.I simply want to make my first major database project a "personalknowledge database" or a "personal encyclopedia", so to speak. By this Imean that I want to gather diverse, multi-format bits of knowledge intoa single database divided into major categories, sub-categories, and soon. For example, I want to scan collected articles from newspapers &magazine and save them as images, type hand-written notes into thecomputer and save them as MS Word or Text files, save audio files withsearchable keywords, even save searchable MS OneNote audio & text files,all into directories & sub-directories. Then I want to be able to searchall these files for specific words or subjects; sort them according todate, subject, etc; update, add to or append, edit, or even cut & paste(within) any of those records in the database, which rely on easilycustomizable formats like text & images (in contrast with audio files orOneNote files, for example).I also want to prevent wasting time in the future, by avoidingrepetitive, same-keywords typing for every non-text new entry, like animage or audio file, by having a customizable keyword list open (byright clicking for example), where one could mark all the relevantkeywords for the picture or audio file. Also have a short descriptionfor each one of those entries when needed. And I want to be able to addslick, good-looking graphics to the interface of the database and theforms of the records.Basically, my priorities include: saving time filling the database withknowledge, quickly & accurately finding the future targets of anysearch, presenting the search results in a highly comprehensible &organized form, and a good looking interface & forms for every entry,which are pleasing to the eye and encouraging to study.I already use graphics applications for the "looks" part. So my questionis: what are the technologies or applications that I should learn byheart and use in order to design such a database in the best way? WouldMS Access alone do it all for me? Or should I learn other technologies?I'll be grateful for anyone taking the time to help. Thanks.Sincerely,Yasso"Claiming that God does not exist because there are people suffering anddying is like saying that barbers do not exist because there are peoplewith long hair! Truth is: they suffer because they did not find God ordo not go to Him, just like the others did not find a barber or do notgo to one."*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Jan 17, 2006
Hello,
I've been trying for a couple of days now with the following problem in SQL
Ive a table called tblRresults that has the following
Date - just a regular date
OfficeLocation - just a unique id such as a zip code
SampleType - contains things like wall, floor, beam
SampleResult - "Detected" or "NotDetected"
When populated the table can look like
12/12/05 99505 Wall Detected
12/12/05 99505 Wall NotDetected
10/04/05 99211 Beam Detected
10/04/05 99211 Beam Detected
10/04/05 99111 Floor NotDetected
10/04/05 99111 Floor NotDetected
What I want is (I guess) a crosstab query that produces the following
Date Location SampleType CountDetected CountNotDetected
12/12/05 99505 Wall 1 1
10/04/05 99211 Beam 2 0 (or null would be ok)
10/04/05 99111 Floor 0 2
Any help gratefully accepted, this has been driving me mental!
thanks
View 2 Replies
View Related
Jun 14, 2002
I am looking into a position requiring "SQL PLUS Expert" - anbody out there heard of this - is it a querying tool a la query analyzer of PL SQL.
View 2 Replies
View Related
Jun 14, 2002
I am looking into a position requiring a "SQL PLUS Expert" - anybody out ther heard of this - is it a querying tool a la query analyzer or PL SQL ?
View 1 Replies
View Related
Dec 11, 2006
Hello,
Lets just say that I have really only logged into phpmyadmin once and messed up my forum.
What I was trying to do? Install a shoutbox (chatroom type software).
When I logged into phpmyadmin I clicked the phpbb_config tab on the left hand side. Then I clicked the SQL tab and pasted the code required for the shoutbox accordingly and hit the "Go" button. But what I did next is what created problems.
I thought I may have put extra spaces or loaded the code wrong in the SQL area because the shoutbox did not work properly after everything was installed. So while in phpmyadmin and after clicking phpbb_config agian, instead of hitting SQL, I hit the "Empty" button thinking that I could just erase what I had previously inserted and then try inserting it again to make sure the code was inserted properly.
If you havn't figured it out by now, I clearly don't have a clue what I am doing, what exactly I did, or what I can do to fix it.
Click on the link to see the error..
http://www.cflzone.com/forum/index.php
Can someone that knows what they are doing please help me???
thanks,
- Reider
View 3 Replies
View Related
Feb 27, 2007
Hello,Consider I have a String:Dim MyString As String = "Hello"or an Integer:Dim MyInteger As Integer = 100or a class which its properties:Dim MyClass As New MyCustomClass
MyClass.Property1 = "Hello"
MyClass.Property2 = Unit.Pixel(100)
MyClass.Property3 = 100Or even a control:Dim MyLabel As Label
MyLabel.Id = "MyLabel"
MyLabel.CssClass = "MyLabelCssClass" Is there a way to save a String, an Integer, a Boolean, a Class, a Control in an SQL database?Something like: Define something (Integer, String, Class, Control, etc) Save in SQL 2005 Database Later in code Retrive from database given its IDIs this possible?How should I do this?What type of SQL 2005 table field should be used to store the information?Thanks,Miguel
View 1 Replies
View Related
Feb 20, 2001
Has anyone any suggestions how I might find the most recent of a series of dates from different tables? I am joining tables which all have a date_altered field and I am only interested in displaying the most recent of these. Eg.
select a.x,b.y,c.z, a.date_altered, b.date_altered, c.date_altered
from a inner join b on (a.id=b,id) inner join c on (b.id=c.id)
What I would like is in effect a function Highest() Eg.
select a.x,b.y,c.z, highest(a.date_altered, b.date_altered, c.date_altered) as last_alteration
from a inner join b on (a.id=b,id) inner join c on (b.id=c.id)
I am using SQL Server 7 so cannot write myself a function to achieve this - frustrating, as it is something I could have done 4 years ago when I used mostly Oracle.
Many thanks
View 2 Replies
View Related
Jul 12, 2004
Fact is:
I have two tables Orderposreg and Temp1 (both in [My Database]), Orderposreg is from 1994, Temp1 from 1995 and i need to Update the old table with the new one.
This should my Query do: I need it to Update old primary keys, or if the row does not exist to insert the new primary key into the Orderposreg.
But if I start the Query i get this failure message:
Server: Msg 107, Level 16, State 1, Line 1
The column prefix 'dbo.Temp1' does not match with a table name or alias name used in the query.
It seems that the colums do not have the same name, but the column of both tables have exactly the same column name and data type just the table name is different.
For your information the whole Code:
Code:
declare @error varchar, @rowcount varchar
select count(*) from dbo.temp1
if (@@error <> 0)
begin
Print 'An error occurred reading the temporary import table'
goto exitpoint
end
begin transaction
update dbo.Orderposreg
set dbo.Orderposreg.Ordernr = dbo.Temp1.Ordernr,
dbo.Orderposreg.Pos = dbo.Temp1.Pos,
dbo.Orderposreg.Produktnr = dbo.Temp1.Produktnr,
dbo.Orderposreg.Artbenämn = dbo.Temp1.Artbenämn,
dbo.Orderposreg.Artikelgrupp = dbo.Temp1.Artikelgrupp,
dbo.Orderposreg.Förs_pris = dbo.Temp1.Förs_pris,
dbo.Orderposreg.Kvant = dbo.Temp1.Kvant,
dbo.Orderposreg.Total_Intäkt = dbo.Temp1.Total_Intäkt,
dbo.Orderposreg.SSort = dbo.Temp1.Sort,
dbo.Orderposreg.Datum = dbo.Temp1.Datum,
dbo.Orderposreg.Utskriven = dbo.Temp1.Utskriven,
dbo.Orderposreg.Levtid_Ö = dbo.Temp1.Levtid_Ö,
dbo.Orderposreg.Levtid_L = dbo.Temp1.Lev_kvant,
dbo.Orderposreg.Inköpskostnad = dbo.Temp1.Inköpskostnad,
dbo.Orderposreg.Vikt_tol = dbo.Temp1.Vikt_tol,
dbo.Orderposreg.AntalSt = dbo.Temp1.AntalSt,
dbo.Orderposreg.Spec_nr = dbo.Temp1.Spec_nr,
dbo.Orderposreg.Spec_utgåva = dbo.Temp1.Spec_utgåva,
dbo.Orderposreg.ID_Beräknad = dbo.Temp1.ID_Beräknad,
dbo.Orderposreg.Bredd = dbo.Temp1.Bredd,
dbo.Orderposreg.Tjocklek = dbo.Temp1.Längd,
dbo.Orderposreg.ValsnGrad_kod = dbo.Temp1.ValsnGrad_kod,
dbo.Orderposreg.Kant_Kod = dbo.Temp1.Kant_Kod,
dbo.Orderposreg.Planhets_kod = Temp1.Yt_kod,
dbo.Orderposreg.LevForm_kod = dbo.Temp1.LevForm_kod,
dbo.Orderposreg.Rakhets_kod = dbo.Temp1.Rakhets_kod,
dbo.Orderposreg.BreddTol_kod = dbo.Temp1.Breddtol_kod,
dbo.Orderposreg.TjocklTol_kod = dbo.Temp1.TjockTol_kod,
dbo.Orderposreg.LängdTol_kod = dbo.Temp1.LängdTol_kod,
dbo.Orderposreg.Stål_kod = dbo.Temp1.Stäl_kod,
dbo.Orderposreg.TotaltSek = dbo.Temp1.TotaltSek,
dbo.Orderposreg.Tullstatnr = dbo.Temp1.Tullstatnr,
dbo.Orderposreg.Fakturera = dbo.Temp1.Fakturera,
dbo.Orderposreg.Leveransstatus = dbo.Temp1.Leveransstatus,
dbo.Orderposreg.Momsbelopp = dbo.Temp1.Momsbelopp,
dbo.Orderposreg.Total_inkl_moms = dbo.Temp1.Total_inkl_moms,
dbo.Orderposreg.KloMPS = dbo.Temp1.KloMPS,
dbo.Orderposreg.ShopFloor = dbo.Temp1.ShopFloor,
dbo.Orderposreg.Status = dbo.Temp1.Status,
dbo.Orderposreg.Stålkod = dbo.Temp1.Stålkod,
dbo.Orderposreg.Kontonyckel = dbo.Temp1.Kontonyckel,
dbo.Orderposreg.PlanLevDat = dbo.Temp1.PlanLevDat,
dbo.Orderposreg.Legtillägg = dbo.Temp1.Legtillägg,
dbo.Orderposreg.StålGrp = dbo.Temp1.StålGrp,
dbo.Orderposreg.KundNr = dbo.Temp1.KundNr,
dbo.Orderposreg.FKundNr = dbo.Temp1.FKundNr,
dbo.Orderposreg.Godsmärke = dbo.Temp1.Godsmärke,
dbo.Orderposreg.LagerMtr = dbo.Temp1.LagerMtr,
dbo.Orderposreg.Sortkvant = dbo.Temp1.Sortkvant,
dbo.Orderposreg.Sortpris = dbo.Temp1.Sortpris,
dbo.Orderposreg.KundsProdNr = dbo.Temp1.KundsProdNr,
dbo.Orderposreg.Godsmärke2 = dbo.Temp1.Godsmärke2,
dbo.Orderposreg.RegDatum = dbo.Temp1.RegDatum,
dbo.Orderposreg.PlanBetDag = dbo.Temp1.PlanBetDag,
dbo.Orderposreg.Säkring = dbo.Temp1.Säkring
where dbo.Orderposreg.Ordernr_o_pos = dbo.Temp1.ordernr_o_pos
select @error = @@error,@rowcount=@@rowcount
if @error <> 0
begin
print ' Error updating - Error number '+@error+'. Rolling back'
--this reverses your updates
rollback
--this jumps to the end
goto exitpoint
end
print @rowcount+' rows updated'
insert into dbo.Orderposreg
(Ordernr, Pos, Ordernr_o_pos, Produktnr, Artbenämn, Artikelgrupp, Förs_pris, Kvant, Total_Intäkt, Sort, Datum, Utskriven, Levtid_Ö, Levtid_L, Lev_kvant, Inköpskostnad, Vikt_tol, AntalSt, Spec_nr, Spec_utgåva, ID_Beräknad, Bredd, Tjocklek, Längd, ValsnGrad_kod, Kant_kod, Planhets_kod, Yt_kod, LevForm_kod, Rakhets_kod, BreddTol_kod, TjocklTol_kod, LängdTol_kod, Stål_kod, TotaltSek, Tullstatnr, Fakturera_kvant, Leveransstatus, Fri_text, Momsbelopp, Total_inkl_moms, KloMPS, ShopFloor, Status, Stålkod_text, Kontonyckel, PlanLevDat, Legtillägg, StålGrp, KundNr, FKundNr, Godsmärke1, LagerMtr, Sortkvant, Sortpris, KundsProdNr, Godsmärke2, RegDatum, PlanBetDag, Säkring)
select
Ordernr, Pos, Ordernr_o_pos, Produktnr, Artbenämn, Artikelgrupp, Förs_pris, Kvant, Total_Intäkt, Sort, Datum, Utskriven, Levtid_Ö, Levtid_L, Lev_kvant, Inköpskostnad, Vikt_tol, AntalSt, Spec_nr, Spec_utgåva, ID_Beräknad, Bredd, Tjocklek, Längd, ValsnGrad_kod, Kant_kod, Planhets_kod, Yt_kod, LevForm_kod, Rakhets_kod, BreddTol_kod, TjocklTol_kod, LängdTol_kod, Stål_kod, TotaltSek, Tullstatnr, Fakturera_kvant, Leveransstatus, Fri_text, Momsbelopp, Total_inkl_moms, KloMPS, ShopFloor, Status, Stålkod_text, Kontonyckel, PlanLevDat, Legtillägg, StålGrp, KundNr, FKundNr, Godsmärke1, LagerMtr, Sortkvant, Sortpris, KundsProdNr, Godsmärke2, RegDatum, PlanBetDag, Säkring
from dbo.Temp1
where dbo.Temp1.Ordernr_o_pos not in (select Ordernr_o_pos from dbo.Orderposreg)
select @error = @@error,@rowcount=@@rowcount
if @error <> 0
begin
print ' Error inserting - Error number '+@error
print ' Rolling back updates and inserts'
--this reverses your updates and inserts
rollback
--this jumps to the end
goto exitpoint
end
print @rowcount+' rows were inserted'
--this saves your data
commit
exitpoint:
Thanks a million for somebody who helps me!!!
View 2 Replies
View Related
Mar 16, 2004
Hi !
I have been worked with VC++, MS SQL SERVER, Transact-SQL for
3 years. I made an axtended stored procedure (xp_test) which returns
an recordset.
From Query Analizer, I can see the recordest : exec xp_test
I want to make an User Defined Function - MyTest which return
the recordset that it is returned by xp_test after its execution.
Something like that :
CREATE function dbo.MyTest ( )
RETURNS @table ...
AS
BEGIN
exec master.. xp_test table1 output -- can I do this ?
RETURN table1
END
Table and table1 are the same design.
Thank you very much !
View 4 Replies
View Related
Feb 27, 2007
Hello,
I am using Enterprise Library Data Access and SQL 2005 application block and I need to know if it is possible to do the following:
Consider I have a String:
Dim MyString As String = "Hello"
or an Integer:
Dim MyInteger As Integer = 100
or a class which its properties:
Dim MyClass As New MyCustomClass
MyClass.Property1 = "Hello"
MyClass.Property2 = Unit.Pixel(100)
MyClass.Property3 = 100
Or even a control:
Dim MyLabel As Label
MyLabel.Id = "MyLabel"
MyLabel.CssClass = "MyLabelCssClass"
Is there a way to save a String, an Integer, a Boolean, a Class, a Control in an SQL database?
Something like:
Define something (Integer, String, Class, Control, etc)
Save in SQL 2005 Database
Later in code Retrive from database given its ID
Is this possible?
How should I do this?
What type of SQL 2005 table field should be used to store the information?
Thanks,
Miguel
View 4 Replies
View Related
Oct 16, 2007
Is there a expert here on full text indexing on 2005 sql server express????
View 8 Replies
View Related
Jan 28, 2008
Hi folks, I have a very typical database for an ASP.net application. There is a table which will contain a hierarchical data..much like files-folders structure of a file system.
But we know that the table will be a giant one in production. There will be a huge collection of data need to persist in it. we are already facing some performance problem with some queries during the QA/test machine.
Currently there is a table which is keeping all file and folder information and another table maintaing their hierarchy relation using two column namely, parentID and childID.
My first question is, would it be better to keep this hierarchy relation into the same table rather using a different one? (much like managerID and empID in AdventureWorks sample?)
My Second question, what is the best way to design this kind of structure to get the highest performance benifit?
All kind of thoughts will be appreciated much! thanks
View 26 Replies
View Related
Oct 26, 2007
Hi,
I have a table describing items with 3 rows:
ID : its an identity Primary key
Type : nvarchar string for itemtype
ItemData : numeric data for an item
I would like to create a query to get the results where each returned row contains
- Type
- number of items for the given type
- concatenated string of the ItemData numbers for all items for the given type
ex: Items
1,"Big",1
2,"Big",56
3,"Small",45
4,"Big",22
Expected result:
"Big",3,"1 56 22"
"Small",1,"45"
I started with this query:
SELECT Type , COUNT(Type) AS Amount FROM Items GROUP BY Type
but i cannot figure out how to do the string concatenation (its like SUM but we dont need to add the values but we need to concatenate). I was thinking some stored procedure but this query will run on Compact SQL so thats not possible according to Compact SQL specs. Can any SQL expert help, how to do this, or is it possible to do anyhow?
Thanks for the help.
View 1 Replies
View Related
Apr 15, 2004
First i am designing a small database fo similar types of books ( Stories table , Short stories table , ...etc ) so i the columns in each table of them is similar , so instead of using a Stored Procedure for every table to select the TOP book i used one SP with variable table name and it works well as i pass the table name from the page , here it is :
---------------------------------------------
CREATE PROCEDURE Top1
@tblname Varchar(255)
AS
EXEC ( 'SELECT TOP 1 *
FROM ' + @tblname + '
WHERE Status="OLD"
ORDER BY ID DESC')
GO
-----------------------------------------------
The Problem now that i want to make the same thing with the INSERT STATEMENT to input new books to the table by passing the table name from the page like the SELECT one , and i `ve tried this one but gives me errors :
--------------------------------------------------------------------------------------------------
CREATE PROCEDURE AddNewStory
@tblname varchar(50),
@title varchar(50),
@Content varchar(5000) ,
@Picture varchar(200) ,
@date datetime
AS
EXEC('INSERT INTO' + @tblname + '( Sttitle , StContent, StPic, StDate )
VALUES ( '+ @Title + ',' + @Content+ ',' + @Picture+ ',' + @date + ')' )
GO
----------------------------------------------------------------------------------------------------
& th error is
Server: Msg 128, Level 15, State 1, Line 2
The name 'Dickens' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
Stored Procedure: db1sql.dbo.AddNewStory
Return Code = 0
SO PLEASE HELPPPPPPPPPPP
View 4 Replies
View Related
Jun 15, 2000
Is anybody out there using SQL Expert Pro? Can you give me some feedback please?
I've been evaluating it for two weeks now and am very pleased with the results but I'm a bit hesitant to spend $5000.
Thanks!
Pete Karhatsu
View 3 Replies
View Related
Dec 20, 2004
Idea here is to output results of a stored proc to a text file..
I am trying to use this query to execute a stored proc which in turn accepts 3 parameters. Can some one help me as I am getting syntax errors when I try this way:
EXEC sp_querytofile 'MyDB', "exec sp_myproc ''11/03/04'', ''ABK'', ''TFC'", 'c:sp_myproc_out.txt'
I tried different combination of quotes but couldn't make it work! Any one to help?
--------code for sp_QueryToFile---------
Create PROCEDURE sp_QueryToFile
( @db sysname,
@query VARCHAR(1000),
@file VARCHAR(255)
)
AS
SET NOCOUNT ON
SET @Query = 'SET NOCOUNT ON ' + @Query
EXECUTE ('master..xp_cmdshell ''osql -w8000 -S sqldev14corpappsdev -r -s" ", -h-1 -o' + @file + ' -d'+ @db + ' -Q"' + @query + '" -E''')
/* Procedure Ends */
View 2 Replies
View Related
Apr 3, 2007
Hi,
I posted last year when we were having problems with a new SQL box we had moved to here...
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74650
...we coded round most of the issues and deadlocks and things seemed to improve for quite a while but we have recently run into performance problems again of late.
The CPUs on our SQL box often thrash away at 100% and our ColdFusion website has begun running painfully slow.
Our developers/hosts have suggested we might need to look for a 3rd party SQL guru who could look at the SQL box, do some tracing etc. and perhaps make some recomendations around optimising the DB architecture or changing the way we run certain queries. At the moment we have only gut instinct on which bits of the DB are likely to be being hit most hard.
Our website has grown from being very small to being really quite busy and it's possible we are running into shortcomings with the design of the DB that need to be tackled before we can expand further.
I'm not sure what the protocol is (I see there is a Jobs part of the site) but I wondered about the possibility of getting one of you guys in for a short while to review our server and database, for a fee of course. I'm not sure how long it would take to review that kind of data and get a feel for the usage?
We are based in the UK and whilst I guess it could be done remotely it might be easiest if the person was UK based too.
I'm as much interested in feedback about the idea (it might be not workable/a good idea for example) as I am to people offering their services.
If this post breaks any rules please let me know.
Cheers,
Tem
View 18 Replies
View Related
Apr 4, 2007
Hello friends,I have to design a database for banking application,but it is my first db design so i need some expert advice.
Data base has some performance constraint i.e high output ,minimum query time,need to process 2 to 5 million transaction per day.
Further specification can be revealed if appropriate help is provided.
your advice will be of great help for me.
Thx
View 4 Replies
View Related
Jul 17, 2006
I have two tables - T_Assets and T_Inspections.
I am trying to create a view where I see the date of the last inspection for each asset. Here is some sample SQL:
SELECT T_Assets.I_AssetID, T_Inspections.I_InspectionID, Max(T_Inspections.SDT_DateOfInspection)
FROM T_Assets
INNER JOIN T_Assets.InspectionID = T_Inspections.I_InspectionsID
GROUP BY T_Assets.I_AssetID, T_Inspections.I_InspectionID
Now, as anyone who is experienced in sql will know, this will not work. This is because the I_InspectionID is different - so the group by will not work. The results I get are basically the same as if the MAX() function was not applied.
Can anyone please tell me a way around this.
Jagdip
View 8 Replies
View Related
Mar 13, 2008
Hi All Professionals Programmers,
I would like to ask a question that is very important for me. The question is how can i create a flexible data base in which i m able to create the inner levels as much as i can.
Like i have a table building, then i have another child table floor, then the floor become parent and i have its child rooms, then the rooms become parent and i have its child floor tiles etc.
you can see i am going to inner dept, so i need a flexible database because its very costly and intimadting to change the database and every time create a new table and relationships.
Hope you have understood what i am going to say and need advice of professional and expert user to resolve it.
Any concise quality material like articles, white paper etc will also be suitable for me.
Thanks in Advance
View 3 Replies
View Related
Dec 22, 2005
hello My SP is as follows
CREATE PROCEDURE SP_ProcessAdminResults(@UserID nvarchar(100)) As
Declare @ReqID as integer;
Declare @Assaignee as integer;
Declare @TechName as nvarchar(200);
Declare @OpenDate as datetime;
Declare @GroupID as integer;
Declare @DateActiontaken as datetime;
Declare @AssignedDate as datetime;
Declare @ActionDays as integer;
Declare @OpenDays as integer;
declare GroupCursor cursor local scroll static for select [ReqID],[Assignee],FullName,[OpenDate],[GroupID],[DateActionTaken] from V_ProcessRequestMaster where UserID=@UserID and [Status]<>'CL' order by ReqID
open GroupCursor
fetch first from GroupCursor into @ReqID,@Assaignee,@TechName,@OpenDate,@GroupID,@Da teActiontaken
while (@@fetch_status <>-1)
begin
select @AssignedDate= min(DateLogged) from LOGMASTER where
analyst=@Assaignee and reqMasterID=@ReqID and UserID=@UserID and Type='INIT'
If @AssignedDate is null
Begin
select @AssignedDate=dbo.GetActionDate(LTRIM(Rtrim(@TechN ame)),@ReqID,@UserID)
End
If @AssignedDate is null
BEGIN
set @ActionDays=0
END
Else
BEGIN
If @GroupID=438030
BEGIN
set @ActionDays=[dbo].GetBussinessdays(@AssignedDate,@DateActiontaken,5 ,6)
set @OpenDays=[dbo].GetBussinessdays(@OpenDate,getdate(),5,6)
END
Else
BEGIN
set @ActionDays=[dbo].GetBussinessdays(@AssignedDate,@DateActiontaken,1 ,7)
set @OpenDays=[dbo].GetBussinessdays(@OpenDate,getdate(),1,7)
END
END
If @ActionDays<>0 set @ActionDays=@ActionDays-1
If @OpenDays<>0 set @OpenDays=@OpenDays-1
update requestmaster set DateAssigned=@AssignedDate, ActionDays=@ActionDays, OpenDays=@OpenDays where ReqID=@ReqID and UserID=@UserID
fetch next from GroupCursor into @ReqID,@Assaignee,@TechName,@OpenDate,@GroupID,@Da teActiontaken
end
GO
The master table contains like 600,000 odd records and when i put a cursor and process the results where i need to get the business days between assigned date and action taken date the query take lot of time and eventually the front end crashes saying Time OUT expired.
Looking for an expert solution to simplify that query.
View 6 Replies
View Related