Examples
Jul 20, 2005
I see a lot of example, but where do these example procedures go. Like
declare (whatever)?
below is an example i read. Where do you put this to make it execute, is it
the view screen or the stored procedure screen?
I'm using MSDE now to learn, and I can't get nothing working except simple
select query statements.
In the northwind example (northwindcs), how would I do a parameter query
like this:
Have a dialog box ask user to enter customerid to bring up. (in a query now
not a form)
Also, how would you check if a certain customerid exist? Example, CHOPS is
one customerid. If I wanted to use a query to check if it exist, and return
no records, but just do an action (like add a record) if it didn't exist,
how?[color=blue]
> CPU SQL
> (ms)
> -- Convert to varchar (implicitly) and compare right two digits
> -- (original version -- no I didn't write it)
> 4546 select sum(case right(srp,2)
> when '99' then 1 when '49' then 1 else 0 end)
> from sf
>
> -- Use LIKE for a single comparison instead of two, much faster
> -- Note that the big speedup indicates that
> -- CASE expr WHEN y then a WHEN z then b .
> -- recalculates expr for each WHEN clause
> 2023 select sum(case when srp like '%[49]9' then 1 else 0 end)
> from sf[/color]
I tried some variations of this, and indeed it seems that there is a cost
when the expression appears with several WITH clauses. I tried a variation
of this, where I supplemented the test table with a char(2) column, so I
could factor out that the WITH clauses themselves were not the culprits.
CREATE TABLE realthing (realta real NOT NULL,
lasttwo char(2) NOT NULL)
go
INSERT realthing (realta, lasttwo)
SELECT r, right(r, 2)
FROM (SELECT r = convert(real, checksum(newid()))
FROM Northwind..Orders a
CROSS JOIN Northwind..Orders b) AS f
go
DBCC DROPCLEANBUFFERS
go
DECLARE @start datetime
SELECT @start = getdate()
SELECT SUM(CASE right(realta, 2)
WHEN '99' THEN 1
WHEN '49' THEN 1
WHEN '39' THEN 1
ELSE 0 END)
FROM realthing
SELECT datediff(ms, @start, getdate()) -- 20766 ms.
go
DBCC DROPCLEANBUFFERS
go
DECLARE @start datetime
SELECT @start = getdate()
SELECT SUM(CASE WHEN right(realta, 2) LIKE '[349]9' THEN 1 ELSE 0 END)
FROM realthing
SELECT datediff(ms, @start, getdate()) -- 8406 ms.
go
DBCC DROPCLEANBUFFERS
go
DECLARE @start datetime
SELECT @start = getdate()
SELECT SUM(CASE lasttwo
WHEN '99' THEN 1
WHEN '49' THEN 1
WHEN '39' THEN 1
ELSE 0 END)
FROM realthing
SELECT datediff(ms, @start, getdate()) -- 920 ms.
go
DBCC DROPCLEANBUFFERS
go
DECLARE @start datetime
SELECT @start = getdate()
SELECT SUM(CASE WHEN lasttwo LIKE '[349]9' THEN 1 ELSE 0 END)
FROM realthing
SELECT datediff(ms, @start, getdate()) -- 1466 ms.
Thus, when using the char(2) column LIKE is slower despite that there
is only one WHEN condition. So indeed it seems that right(realta, 2)
is computed thrice in the first test.
Another funny thing is the actual results from the queries - they are
different. When I ran:
select count(*) from realthing where lasttwo <> right(realta, 2)
The result was about half of the size of realthing! I can't see that
this difference affects the results though.
Now, your article had a lot more tests, but I have to confess that
you lost me quite early, because you never discussed what is the
actual problem. Since you are working with floating-poiont numbers
there is a great risk that different methods not only has different
execution times, but also gives different results.
--
Erland Sommarskog, SQL Server MVP, Join Bytes!
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
View 2 Replies
ADVERTISEMENT
Feb 18, 2002
Are there any examples of using DTS and XML/XLS? specifically, importing data. I have searched through BOL and cant find any, nor is there any reference to XML in the book "Professional SQL 2000 DTS"
Many thanks
View 2 Replies
View Related
Apr 29, 2004
Does MSDE have the PUB database example in it? Just wondering before I download it.
View 2 Replies
View Related
Jul 23, 2005
What is the purpose of the "N" preceding the parameter values in theSQL examples?Here is an example copied from Books Online, SP_ATTACH_DB:EXEC sp_attach_db @dbname = N'pubs',@filename1 = N'c:Program FilesMicrosoft SQLServerMSSQLDatapubs.mdf',@filename2 = N'c:Program FilesMicrosoft SQLServerMSSQLDatapubs_log.ldf'I've found that my sp_attach_db routine works without the "N", but Ineed to know what it is that I don't know.Thank you everybody for all your help.
View 1 Replies
View Related
Jan 3, 2007
Hello all,
I want to use SQLCE and WPF.
Can anyone direct me to some example code.
two way binding with a sqlceResultSet would be a great start.
(last inquiry was in Aug of 06)
Thanks
Mike (still trying to get the latest tech to work together) Greenway
View 6 Replies
View Related
Jun 30, 2006
Hi!
Where can i find examples of T-SQL executed by one instance of SQL Server 2000 to communicate to a 2005 SQL Broker instance (both located on the same server)?
thanks for your help!
View 2 Replies
View Related
Mar 28, 2006
Hello, Can anyone direct me to some sample charts created with 2000 Reporting Services? Looking for the advanced capabilities and quality of the charts.
Thanks
SactoJoe
View 3 Replies
View Related
Nov 21, 2007
hican someone help me. i am looking for free databanks. i could use asexamples for testing the usage of them. just for a start getting intothis field.i appreciate your help. thx ann xx
View 1 Replies
View Related
Jul 20, 2005
Hello there:I am trying to configure an excel worksheet as an Writebackapplication but I want to block some cells in the page and combiningcell protecion does nos alloudm to insert rew rowns
View 2 Replies
View Related
Jul 20, 2005
Hi..Im newbie on Report Services with VS.NET... I made a cube on olap.. andI try to lear some mdx for my reports..But, in the report designer... I need a lot of help..Please.. anybody.. can help me¨??Thanks a lot...!Karina Gamez*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!
View 1 Replies
View Related
Jul 6, 2006
Hi!
I was just wondering if there are any examples on how to work with the Script Editor, and more specifically how to use the DirectRow method? I've seen some examples that say that the editor automatically creates the methods DirectRowTo<output buffer>, but it doesn't say how that is done. If I just specify Row.DirectRow(output buffer #), it says that the method is protected.
Any help or just pointing me in the right direction would be greatly appreciated!
Thanks!
Jeff Tolman
E&M Electric
jeff.tolman@enm.com
View 4 Replies
View Related
Mar 28, 2006
I have been creating SSIS packages programmatically and have run into somewhat of a dead end. I have found the examples provided with the SQL 2005 install very helpful, but they only cover setting up three tasks: Sort task, OleDB Source and a Flat File Destination.
Does anyone have any examples or knows of examples of using the Merge Join task and the Conditional Split task?
I'm doing it all programmatically and so far I'm having trouble finding much in the way of documentation or examples.
Any help would be great!
Thanks,
Mark
View 8 Replies
View Related
Oct 26, 2006
Hi,
I'm new to SQL Server Technology and am trying to learn how to create a Mobile Device application and to sync it with a desktop application that uses Access. I have found a lot of information but some of it doesn't seem to make sense.
I found this blog: http://blogs.msdn.com/sqlservereverywhere/archive/2006/08/29/729730.aspx which is the announcement of Access Database Synchronizer (ADS) CTP. I downloaded it and installed it with all the prerequisites. This is the part i can't understand:
"The CTP setup installs the desktop component required for synchronizing Microsoft Access database with SQL Server Everywhere Edition database on the device."
I cannot seem to find the desktop component to try out! The Readme shows you how to pull and push data but i can't see where the desktop data sync wizard is located. Should there be something installed on my desktop that i can see?
Also, there doesn't seem to be much help or examples around on this component as yet. Can anyone point me in the right direction for examples, help, or tutorials on this.
This paragraph also confuses me:
"Note: As of today only SQL Server Mobile Edition is available for devices. SQL Server Everywhere Edition whould be available for devices at time of SQL Server Everywhere Edition RTW whihc is planned for November 2006".
Does this mean SQL Everywhere won't work on mobile devices until November?
Sorry for all the questions but i'm still trying to learn this stuff so i can write my application for Windows CE. Thanks in advance.
View 8 Replies
View Related
Apr 3, 2006
books online mentions examples stored on the pc when sql is installed, but the examples are not on my machine. i know they are on the disk somewhere, but i dont have the disk. i have tried going to add remove programs and adding extra sql components but i cant find the examples there either. can anyone tell me where to find them?
View 1 Replies
View Related
Jun 20, 2007
i have posted here a few times on my endpoint issues but i cant find a resolution so im approaching the issue from a different angle. can you guys tell me how you create and consume endpoints, preferably with the endpoint code, the url you use to see the wsdl, and any network/pc settings you may have altered to get endpoints to work. im looking for tips or steps that may not be included in basic endpoint tutorials. I really am stuck and have no idea what else to try. thanks all
View 3 Replies
View Related
Apr 30, 2004
Does anyone know where I can find a Northwind end to end database solutions (examples) written in ASP.NET (VB). I would like to reverse engineer this project to learn more about ASP.NET?
Thanks.
View 1 Replies
View Related
Feb 25, 2005
Hi
I'm learning by going through the tutorials and such and modifying the code to try and learn how to do more and different things.
I have a MSDE Database, and I'm building a query from the WebMatrix Code Builder.
I can get a Select and Where to work on a "Category" colum as String; to return from a text box control (where I enter the name) and on button click.
What I would like to learn how to do and am having trouble is do a select Where "Category" (string) and "Status"(Int) are the same.
I have two Seperate Textboxes after i make the Where / And Query, but I'm not sure i have the button click code right.
I have included the code below - Sorry if this is so basic ;-) - The Sub_Button1 Click is at the end.
Function ShowRecords(ByVal category As String, ByVal status As Integer) As System.Data.DataSet
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='SalesContacts'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [Contact].* FROM [Contact] WHERE (([Contact].[Category] = @Category) AND ("& _
"[Contact].[Status] = @Status))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_category As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_category.ParameterName = "@Category"
dbParam_category.Value = category
dbParam_category.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_category)
Dim dbParam_status As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_status.ParameterName = "@Status"
dbParam_status.Value = status
dbParam_status.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_status)
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = ShowRecords(CStr(TextBox1.Text)&(CInt(TextBox2.Text)))
DataGrid1.DataBind()
End Sub
View 4 Replies
View Related
Jun 17, 2002
Hi Guys!
What's the best way to keep an audit trail of every insert, update, and delete of a certain table? Any example code out there? I'm thinking in terms of a trigger for each event, for instance, the update trigger would insert a new record into the audit table with a field for each column in the deleted table and a field for each column in the inserted table.
Thanx
Dave
View 3 Replies
View Related
Feb 13, 2007
BOL only seems to say that you can do it w/o really showing how, and the ExternalActivator sample at gotdotnet.com contains so much functionality I'm not sure what's required just for the external activation. Are there any docs or samples out there that focus on how to do it w/o obscuring the matter with a bunch of other functionality? (I prefer docs to project samples, b/c the samples tend to have hacks like hardcoded paths and connection strings so that they rarely work correctly right out of the box.)
TIA
View 1 Replies
View Related
Mar 30, 2008
Am new to SSIS, I saw only few examples from the textbook but i need to learn a lot from the ssis , so can any one suggest me where can i find good examples and small projects , so that i can get more practise on the ssis.
Thanks ,
Raj
View 3 Replies
View Related
Jul 17, 2005
Recently there has been questions on some of the newsgroups about examples for SQL Server Service Broker. So, yesterday on a flight back to England I crofted up three different SQL Server projects as examples: LocalSampleRemoteSampleServer1RemoteSampleServer2
All three examples are jus your very basic €œHello World€? example, but they show: LocalSample €“ communication between two databases on the same SQL server instance. MasterKeys in a database and the database being TrustWorthyRemoteSampleServerX €“ These two samples are meant to run on two different machines/instances and in the samples you set up both transport security and dialog security by using Certificates.
Download the zip file from here [0], unzip and read the README.txt file, and €“ Have Fun!!
[0] : http://staff.develop.com/nielsb/code/servicebrokerexamples.zip
View 6 Replies
View Related
Nov 8, 2007
Hi,
I have installed SQLServer 2005 along with Visual Studio 2005 Professional. I am trying to study some database examples (CreateDB for example) but I always get the mesage that I need the Northwind database installed. I cannot find it anymore in the examples provided for SQL Server 2005. In the links provided after the error is displayed, I find that I should install SQL Server Express. I do not really want that because of some possible conflicts with the other 2005 version of SQL Server.
Is there a place I can download the Northwind database from? Will it work with SQL Server 2005?
Thank you.
View 3 Replies
View Related
Sep 18, 2007
Hi,
I have seen many examples at MSDN library related to SQL Querries in all queries one thing is same the way they use tables in there queries. BUT wht is this really i am not getting this, can anyone tell me.. the code and the problem is as follows:
Code Snippet
FROM Purchasing.ProductVendor JOIN Purchasing.Vendor
ON (ProductVendor.VendorID = Vendor.VendorID)In the above code u see "Purchasing.ProductVendor", I want to ask that wht is this
Purchasing Stands for, If we suppose that purxchasing is the database name then also
normally we use database name as Purchasing.dbo.ProductVendor BUT I am not getting that
what is this,
Please if someone knows then explain it to me,
Thanks.
View 2 Replies
View Related
May 24, 2006
Hi, is there any tutorials out there that teaches newbies how to use Stored Procedures? I am using SQL Express with ASP.Net 2.0. Please help and thanks in advance.
View 1 Replies
View Related
Sep 18, 2006
The free one that i have downloaded doesn't seem to be able to view the database. Is there any free database which i can download? Please advise. Thanks.
View 1 Replies
View Related
Feb 8, 2006
Hi,
Near the end of 2005 Microsoft made available some sample C# apps that implemented custom SSIS tasks and components. I think Doug Ladenshlager may have had a heavy hand in building them.
Does anyone know where they are? I can't darned well find them!
-Jamie
View 1 Replies
View Related
Jul 31, 2007
Hello,
My C# .NET application is currently using the System.Data.OleDb namespace to access SQL Server 2000 and SQL Server Express databases. I would like to begin using SQL Server Compact Edition to access a local database that has the same structure as the others. I'd like to use the same code regardless of the data source, so I would prefer to use System.Data.OleDb instead System.Data.SqlServerCe.
Where can I find examples of the use of System.Data.OleDb with SQL Server Compact Edition? Some of the specific questions I have are:
1.) How do I build the connection string for the OleDbConnection object?
2.) What are the limitations, if any, of using OleDb instead of SqlServerCe?
I will appreciate any help you can provide.
Thank you,
WTW
View 1 Replies
View Related
Aug 17, 2007
Does anybody know how to generate a new identity value from within SSIS. Can anybody point me to a good example using a script component?
Thanks you very much!!!!
Sergio
View 2 Replies
View Related
Sep 17, 2007
Code Snippet
SELECT 3308 / 15104
The above division will result with: 0
Code Snippet
SELECT 3308 / (15104 * 1)
The above division will result with: 0
Code Snippet
SELECT 3308 / (15104 * 1.0)
The above division will result with: 0.219014830
MY MAIN GOAL is to produce a result of: 0.2
I was thinking of using ROUND, then with some combination of RIGHT. Your explanation and advice is greatly appreciated! Thanks again!
View 3 Replies
View Related
Oct 30, 2006
I have gone through BOL and various online resources including this one and I can't find any examples on how to use custom conflict resolvers to generate a result row which is a combination of the rows to be merged.
BOL says it can be done, but suitable examples are missing. I have found various posts requesting examples from up to a year ago, but can see no replies with relevant information
In particular I would like to see examples of
1) A stored procedure based custom conflict resolver
2) A business logic handler written in VB .Net
Here's hoping
aero1
View 16 Replies
View Related
Apr 4, 2006
Hi
I am looking at documentation of CREATE CERTIFICATE statement. I am having hard time in understanding if I want to create CERTIFICATE with above mentioned options, how I am supposed to create either PRIVATE KEY file or EXECUTABLE file. any example would be really helpful for what I am doing here.
thanks
Satya
View 1 Replies
View Related
Jan 11, 2008
Hi all,
I copied and executed the following sql code in my SQL Server Management Studio Express (SSMSE):
--SELECTeg8.sql from SELECT-Using correlated subqueries of MSDN2 SELECT Examples--
USE AdventureWorks ;
GO
SELECT DISTINCT Name
FROM Production.Product p
WHERE EXISTS
(SELECT *
FROM Production.ProductModel pm
WHERE p.ProductModelID = pm.ProductModelID
AND pm.Name = 'Long-sleeve logo jersey') ;
GO
-- OR
USE AdventureWorks ;
GO
SELECT DISTINCT Name
FROM Production.Product
WHERE ProductModelID IN
(SELECT ProductModelID
FROM Production.ProductModel
WHERE Name = 'Long-sleeve logo jersey') ;
GO
=========================================
I got:
Results Messages
Name o row affected
========================================
I think I did not get a complete output from this job. Please help and advise whether I should search somewhere in the SSMSE for the complete results or I should correct some code statements in my SELECTeg8.sql for obtaining the complete results.
Thanks in advance,
Scott Chang
View 5 Replies
View Related
Sep 28, 2007
Hi all,
I want to do SQLCLR by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express and I have read the following articles and books:
(i) Connecting to SQL Express User Instances in Management Studio in http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-insta...
(ii) Managing SQL Server Express with SQL Server 2005 Management Studio Express Edition in http://www.microsoft.com/technet/sql/2005/mgsqlexpwssmse.mspx
(iii) Chapter 16 - Going Beyand Transact-SQL: Using the SQL Common Language Rutime (SQLCLR) in Microsoft SQL Server 2005 Express Edition for Dummies
(iv) Chapter 21 - Working with the Common Language Runtime in Microsft SQL Server 2005 Programming for Dummies
(v) Chapter 4 - Introduction to Common Language Runtime (CLR) Integration in Programming SQL Server 2005 by Bill Hamilton.
I want to create an SQLCLR project "HelloWorld" by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express. But I am still not sure how to get it started, because I do not understand the following things:
(1) Pipe Name for a User Instance, (2) Enabling (or Disabling) the CLR by using Transact-SQL, (3) Creating a Transact-SQL script, (4) Creating an Assembly, (5) Creating a backup device, etc. I need to see some simple examples of SQLCLR by Connecting to SQL Express User Instances in Management Studio via VB 2005 Express. Please help and tell me where in the websites I can find them.
Thanks in advance,
Scott Chang
View 5 Replies
View Related