I have two tables CarType & Cars. Table CarType has a column CarTypeId which is the primary key (int, identity). Table Cars includes a column CarTypeId (int) which is a foreign key into the CarType table.Now I am trying to build a list of all those CarTypeId entries (from the CarType table) for which there are no Cars (i.e. there is no corresponding entry in the Cars table).I read that there is an SQL "MINUS" keyword that you can use like this:
SELECT CarTypeId FROM CarTypeMINUSSELECT CarTypeId FROM Cars..So if CarType contains records with the keys {1, 2, 3, 4, 5} and Cars contains records with the foreign keys {2, 4} (using set notation), your result should be the set {1, 3, 5}. (Note: I have tried alternate versions of this where I selected the DISTINCT CarTypeId entries from Cars, and where I sorted them; results same in both cases).I tried it in SQL Server 2005 Express. The result is just {1, 2, 3, 4, 5}.
Is the MINUS capability supported by SQL Server? I know that there are all sorts of different SQL dialects & implementations and that SQL has evolved & transmutated over the years; perhaps they opted to leave this out of SQL Server..
Here's a reference to the website where I initially found out about MINUS: [URL] ....
I'm creating a software, and I have a dilemn... To check it I use MySQL, but I want my software to use a lot of kind of différent DB (oracle, DB2, informix, etc...)
But I have to know :
Does MSSQL support something like that (and if not how to do it) :
SELECT fields FROM Table LIMIT 0,500
????
thank you very much for a quick answer, because All development depend of the answer !!!
I have no problem getting OLE DB Command transformations to support single returns by a procedure.
For example, exec name_of_procedure ?,?,? OUTPUT
However, I have a stored procedure which accepts 1 input and returns 5 outputs. This procedure works fine at the command line but when I try to incorporate it into a OLE DB Command I don't get the multiple values returned. There's no problem at all configuring the transform as it recognizes all input and output parameters. For some reason I just don't get values returned.
I have the following sql string in my asp.net, its meant to retreive a value based on a text box value being "like" a value from my database, however when i place a word in the textbox nothing happens, can someone please take a look at the statement and see if its well formed, String sql = "SELECT fName FROM Customers WHERE fName LIKE " + "'" + fName.Text + "/%' OR PostCode= " + "'" + Postcode.Text + "'";
hi, i want to do search by keywords for e.g "John Smith". should search for "John" and "Smith" it is easy to do it using dynamic sql statement. but i am using parameters sql. this is my sql "select * from emp_tbl where fname like '%' + @keyw + '%' or lname like '%' + @keyw + '%' " the above sql will search by full phrase how can i make it search each word in the phrase.
aslo, i am searching for 70-551 exam. to upgrade my mcad to mcts. can anybody help.
Hello everyone, I'm working on a SQL statement that I "thought" worked fine until I noticed I was getting a duplicate row. Below is the SQL statement from the stored procedure: SELECT DISTINCT number AS 'RteNum', leg_orig AS 'Origin', leg_dest AS 'Dest', AcEquipment.EquipmentDesc AS 'EquipType', SUBSTRING(trailer_option, 1, 1) AS 'TrailerOption', leg_depart_time_local AS 'DeptTime', leg_arrive_time_local AS 'ArrTime', dev.fnConvertEffectiveDaysToDaysOfWeek(SUBSTRING(leg_effective_local, 2 ,7)) AS 'EffectiveDays', TruckEditor.EffectiveDays as 'NewEffectiveDays' FROM lhif_prod JOIN AcEquipment ON AcEquipment.EquipmentType = lhif_prod.Equipment_Type LEFT JOIN dev.TruckEditor ON TruckEditor.Origin = lhif_prod.leg_orig AND TruckEditor.Dest = lhif_prod.leg_dest AND TruckEditor.RouteNum = lhif_prod.number AND TruckEditor.DeptDate = lhif_prod.leg_depart_date_local WHERE leg_depart_date_local BETWEEN @DateStart AND @DateEnd AND Type_Code = 'T' AND leg_orig = @LocID ORDER BY RteNum, Dest, DeptTime Here is what comes back from this query:ABE00 ABEA ABER CTV5 H 1855 1915 MTWT--- NULLABE01 ABEA ABER CTV5 H 1941 2001 MTWT--- NULLABE02 ABEA ABER CTV5 H 2045 2105 MTWTF-- NULLABE03 ABEA ABER CTV5 H 2059 2119 MTWTF-- NULLABE04 ABEA ABER CTV2.5 H 2245 2305 MTWTF-- NULLABE11 ABEA ABER WALKIN H 2045 2100 MTWTF-- NULLABE11 ABEA ABER WALKIN H 2045 2100 MTWTF-- MT-TF--ABE12 ABEA ABER WALKIN H 2109 2124 MTWTF-- NULLEF038 ABEA EWRHB 53BULK H 0100 0245 -TWTFS- NULLEF085 ABEA EWRHA CTV5 H 1955 2140 MTWT--- NULLEF106 ABEA EWRHB CTV5 H 1901 2046 -----S- NULLEF140 ABEA ABER CTV5 H 0550 0610 M------ NULLEF166 ABEA EWRRA CTV5 H 2230 0010 MTWT--- NULLEF366 ABEA EWRRA CTV5 H 2230 0010 ----F-- NULLEF543 ABEA EWRRA CTV5 H 2200 2345 MTWTF-- NULL The 2 rows in bold are the issue right now. There should only be 1 row (the 2nd one where the last column is not null). I'm not sure why it returns both columns when I'm doing a join on there to add that last column. Can anyone help me out with this? I'm not very strong in SQL, so if I'm overlooking something, I'd appreciate any help you can provide. Thanks.
Following is the stored procedure iam trying to create.Here i am trying to
First create a table with the table name passed as parameter Second I am executing a dynamic sql statement ("SELECT @sql= 'Select * from table") that returns some rows. Third I want to save the rows returned by the dynamic sql statement ("SELECT @sql= 'Select * from table") in the tablei created above.All the columns and datatypes are matching.
This table would be further used with cursor. Now i am getting a syntax error on the last line.Though i doubt whether the last 3 lines will execute properly.Infact how to execute a sp_executesql procedure in another dynamic sql statement.ANy suggestions will be appreciated.
i have two machines. i was working in a "Execute SQL Task" object's SQL window on a rather long sql task on one machine and reached some kind of limit on the length of the sql statements. i can not add another line of code. i cut and pasted this same code into the exact same "Execute SQL Task" object's SQL window on the second machine and it does not have this limit. does anyone know what causes this? (in fact....i could paste it in twice - doubling the length)
i have the following union statement, which works like a charm:SELECT [Name], [EventID] AS [ItemID], [TourID], [Date], NULL AS [StartDate], [Date] AS [SortDate], [Type] FROM [Events] WHERE [TourID] IS NULL AND AccessLevel <= @AuthenticationLevel UNION SELECT [Name], [TourID] AS [ItemID], [TourID], NULL AS [Date], [StartDate], [StartDate] AS [SortDate], '2' AS [Type] FROM [Tours]WHERE AccessLevel <= @AuthenticationLevel ORDER BY [SortDate]
now i want to ad a limit to this statement, but i can't get it working. i have tried this:SELECT * FROM (SELECT [Name], [EventID] AS [ItemID], [TourID], [Date], NULL AS [StartDate], [Date] AS [SortDate], [Type] FROM [Events] WHERE [TourID] IS NULL AND AccessLevel <= @AuthenticationLevel UNION SELECT [Name], [TourID] AS [ItemID], [TourID], NULL AS [Date], [StartDate], [StartDate] AS [SortDate], '2' AS [Type] FROM [Tours]WHERE AccessLevel <= @AuthenticationLevel) ORDER BY [SortDate] LIMIT 2 but i keep getting an error message saying "Incorrect syntax near the keyword "ORDER". what am i doing wrong?
Reader Community I've just started hosting my newly created Microsoft Visual Web Developer 2005 Express Edition web site. Unfortunately the Login group membership functions will not function correctly. Having contacted the web service hosting provider, They replied: "We do not support SQL express2005. The only way to use the extra functions of ASP.NET2 such as group membership is if it is using an SQL 2000 database to connect to. " Is it possible to design web sites with Microsoft Visual Web Developer 2005 Express Edition that store membership details on an SQL 2000 database? I've just paid £88 approx. $140 for a years subscription, have I chosen the wrong web service hosting provider? Should I have designed the web site with a better web site design software tool that also makes designing membership login functionality easy, just as Microsoft Visual Web developer 2005 express edition? Look forward to all comments? Regards
Hello there. I'm developing an eCommerce solutions based on the ASP.NET 2.0 Commerce Starter Kit, architechture. It uses the Provider Pattern. In my web-application, i use the CatalogProvider, to retrieve data from a SQL Server 2005 database. I call the methods through a handler class, whoch excists inside the WebApp. I also use a ShoppingCartProvider, OrdersProvider, ShippingProvider etc. in the same way. In my Web.Config file, i have all the provers listed, and on each provider, the name of the connectionString to use are given. My connection string looks like this:"connString" connectionString="Server=xxxx;Database=xxxx;Trusted_Connection=True;" providerName="System.Data.SqlClient" /> The problem is, that suddently, when browsing the website, that connects to the database through the providers, i get this error: Keyword not supported: ',server'. 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.ArgumentException: Keyword not supported: ',server'.Source Error:
Line 31: public static IDataReader GetProductsByCategory(int categoryID) Line 32: { Line 33: return Commerce.Providers.CatalogProvider.Instance.GetProductsByCategory(categoryID); Line 34: } Line 35: Source File: d:DevelopmentASPNETSeoShopApp_CodeHandlersCatalogManager.cs Line: 33 Stack Trace: If i then go back to my web.config file, and removes the providerName section, of the connectionString, the website works again, for a short period. When the error return, i undo the deletion of the providerName, and it will work again... For a short time... I've also tried to use another connectionsString, like this:Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI But then the keyword which is not supported is: ', data source'
Does anyone know what the issue might be? Thanks in advance...
I am using the top keyword as follows in the same SP. The select and the update statements are one below the other: Select TOP(1) col1,col2 from table1 where col3='val1' Update TOP(1) table1 set col2= 'val2' where col3='val3' There is a primary key on the column which is not included in either the select or the update statement. Can anyone confirm that the both the statments will return the same row?
im trying to find the equivalent of the below oracle code in sql server.But to my knowledge i feel "translate "is not supported by sql server. so please send me the equivalent sql server query for this.SELECT 'http://ploft.com/ploft?y='||translate(comp,' ','+')||',+'||translate(california,'','+')||',+'||ca||'+'||pzINTO :ls_MAP FROM project WHERE portno=:dbno;
Full Text search must keep a list of key words or items somewhere. How can I get access to this list to present to a user. For example: show me all indexed words starting with letter a* and then ac*. I'm trying to find this information without success.
Hi, I using "Microsoft SQL Server 9.00.3042.00" at home. But our company old system using "Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) ". I think therefore i showing this error when running.
Query: SELECT @@VERSION Results: Microsoft SQL Server 2000 - 8.00.2039 (Intel X86) May 3 2005 23:18:38 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2) ------------------------------------------------------------------------------------------------------------------- Query: GO CREATE VIEW dbo._UrunAgaci_KullanimMiktarlari AS WITH RPL (AnaUrunKod, BilesenKod, BilesenMiktar) AS ( SELECT ROOT.AnaUrunKod, ROOT.BilesenKod, ROOT.BilesenMiktar FROM _UrunBilesenListesi ROOT /* WHERE ROOT.AnaUrunKod = '100.0.622' */ UNION ALL SELECT PARENT.AnaUrunKod, CHILD.BilesenKod, PARENT.BilesenMiktar*CHILD.BilesenMiktar FROM RPL PARENT, _UrunBilesenListesi CHILD WHERE PARENT.BilesenKod = CHILD.AnaUrunKod ) SELECT AnaUrunKod, BilesenKod, SUM(BilesenMiktar) AS [TopÄ°ht] FROM RPL GROUP BY AnaUrunKod, BilesenKod; GO Results: Server: Msg 156, Level 15, State 1, Procedure _UrunAgaci_KullanimMiktarlari, Line 3 Incorrect syntax near the keyword 'WITH'.
I've run into a bit of a database connection problem. I'm trying to connect to a SQL Server database. It compiles okay, but then while IE is loading, I get an exception error pointing out in the code saying 'Keyword not supported: 'provider'.
I am searching for the key word 'Platform Customer Support' using full text search. My code is as below
Set @KeywordSearch = 'Platform Customer Support'
Select AA, BB, CC, DD from SM9..TableName A Right Outer Join SM9_Experiment..TableName C On A.IncdTouchedGSF like '%' + C.SM9GroupName + '%' Where ( Contains(A.[Description], @KeyWordSearch) And A.OpenTime Between @StartDate and @EndDate And C.Classification = @GroupNameClassification )
The code is throwing:
Msg 7630, Level 15, State 3, Line 46 Syntax error near 'Customer' in the full-text search condition 'Platform Customer Support.
I'm storing time series data in a table in SQL server 2000. The tablehas columns like: CodeEquity, PriceDate, LastPrice. To extract thelast price for a number of equities on COMMON DATES I have used thequery:select t.LastPrice,h1.LastPrice,h2.LastPrice,h3.LastPrice fromBlg_HistoricData t,Blg_HistoricData h1,Blg_HistoricDatah2,Blg_HistoricData h3where t.CodeEquity=114151 and h1.CodeEquity=112220 andt.PriceDate=h1.PriceDate and h2.CodeEquity=112580 andt.PriceDate=h2.PriceDate and h3.CodeEquity=112228 andt.PriceDate=h3.PriceDatethis works for about 20 self joined tables and then says syntax error.I'm wondering what sql limits it hits. Is it possible to do this inSQL for 300 tables?Thank you.
UAT environment : SQL Server 2008 R2 SP3 Enterprise Edition
SANDBOX environment : SQL Server 2008 R2 SP3 Standard Edition
I have a database backup (.bak) that was taken from UAT environment that has CDC enabled on some tables. I want to restore that database into my SANDBOX environment which does not support CDC (because of standard edition). The restore process fails due to this incompatibility. Is there any way to restore without CDC (I dont CDC enabled on my SANDBOX; just my data from the backup) ?
I have used this mysql code in my programm before:
select * from address order by vorname asc limit 0, 10
It works fine. But now I want to use sql server, and it doesn't recognize the term limit. So I have found out that I can use top instead. I have changed my code into this:
select top 0 * from (select top 10* from address order by vorname) order by vorname asc
I was wondering what more experienced DBAs have observed with regard to the capacity of a MSSQL DB. Is there an upper threshold of rows where performance becomes unacceptable? I have a fairly slow, but constant input rate of approximately 2,000 rows every 60 seconds or so (that is a little high, but I'm interested in worse case scenario here). That is up 172,800 rows a day. (I'm being overly pessimistic here.) We'd like to be able to keep all of this around as long as possible.
Or would a more heavy duty DB be in order for these sorts of data rates?
Hi, I need some help about a project I'm working on.
I'm working on a project (based on MS SQL Server) that will involve a lot of clients, each one constantly querying the server. Just to have an idea of the project, I'm talking of about 2000 clients, each one queries the database 3-4 times per second: a total of 6-8000 queries per second. The database is reached through Internet and every client uses a dedicated DSL connection.
My questions are: - What is the maximum workload of a Microsoft SQL Server? - What happens when the server workload reaches 100%? is there a queue? and what happens when the queue is full? is it possible that the server goes out of service due the excess of work? - What are (more or less) the hardware requirements for such a server?
can anyone help me, at least telling me how to find these answers (web sites, books, ...)