sql-server

Query Performance - Inner Join

I have this query and I want to improve performance: SELECT OrarioA, OrarioB, IDOrario, IDDettaglioOrarioA, IDDettaglioOrarioB FROM ( SELECT Tb_01.Orario AS OrarioA, Tb_02.Orario AS OrarioB, Tb_01.IDDettaglioOrariLinee AS IDDettaglioOrarioA, Tb_02.IDDettaglioOrariLinee AS IDDet...

The equivalent of SQLServer function SCOPE_IDENTITY() in mySQL?

What is the equivalent of SQLServer function SCOPE_IDENTITY() in mySQL? ...

How to model a "left join" in SQL Server Reporting Services?

Hello, I'm new to reporting svcs and I'm writing a report based on a report model (.smdl) created in VS.NET 2008. I seem to be missing out on the report builder query view's analog to a "left join." Model is very simple: Three entities: Cust (custid, custname) Ord (ordid, custid, orddate, ...) Charge (chargeid, ordid, chargetype, cha...

How Can I add the 2D array in SQL server 2000 using c#

Hi all, I want to add the 2-dimentional array in the sql server 2000 using c#. But the problem is that there is not array data type in sql. Kindly help me that how can I add the 2-dimentional array in sql server. Thanx for viewing my question... ...

Does Visual Studio Professional come with SQL Server Developer (not Express) edition?

A co-worker and I are disagreeing on this. He thinks we have licenses for SQL Developer because we purchased VS 2005 Professional. It's been a while since I've installed it but I don't recall that being part of the installation whatsoever. It's always been a separate install and license. Been to the MS VS site and can't find anything...

How do I join a select distinct to a select sum?

I am trying to join a select disinct statement to a select sum statement. Here is an example of the data CD STDATE ENDDATE PR F1 01/02/09 01/04/09 $10 F1 01/02/09 01/04/09 $40 F1 01/02/09 01/04/09 $20 F1 01/02/09 01/04/09 $30 F1 01/22/09 01/26/09 $10 F1 01/22/09 01/26/09 $50 F1 01/22/09 01/26/09 $20 My desi...

How to Export binary data in SqlServer to file using DTS

I have an image column in a sql server 2000 table that is used to store the binary of a pdf file. I need to export the contents of each row in the column to an actual physical file using SqlServer 2000 DTS. I found the following method for vb at http://www.freevbcode.com/ShowCode.asp?ID=1654&NoBox=True Set rs = conn.execute("selec...

How do you use a binarywriter to write the correct MS SQL native format for the Money data type?

How do you use a binarywriter to write the correct MS SQL native format for the Money data type? I'd like to take a value in .net, read from a file as string representation of a decimal amount (actually an exported "Money" data type from SQL, but that is unimportant). How can I use a binary writer to write the value so that you can u...

SQL 2005 Select data where conversion fails

Is there any way for me to test a data conversion in a select statement and only return rows where the conversion fails? IE: SELECT * FROM my_table WHERE CONVERT(datetime, [colA]) = NULL I'm open to any SQL hacks/trickery. ...

SQL Server 2005 LENfunction oddity

The following code: if (right(@eqlist,2) = ', ') set @eqlist = left(@eqlist,len(@eqlist)-2) produces different results (with the same data) on my production server than on my development server. The problem is that the LEN function is 'supposed' to trim off the trailing spaces before calculating the length of a string, but it doesn...

SQL Server SELECT/UPDATE Stored Procedure Weirdness

I have a table I'm using as a work queue. Essentially, it consists of a primary key, a piece of data, and a status flag (processed/unprocessed). I have multiple processes trying to grab the next unprocessed row, so I need to make sure that they observe proper lock and update semantics to avoid race condition nastiness. To that end, I'...

How Do You Tell What Next Identity Column Will Be?

Is there a tsql query to tell what SQL server identity column value it expects to use for the next row insert? Edited to add: I deleted and recreated a table with [personID] [int] IDENTITY(1,1) NOT NULL as part of my CREATE TABLE command. I've also attempted to reseed identity columns while removing all information in that table a...

How can I get the identity of a row that was just added to a DataTable?

Say that I have this code: rentalEaseDataSet.tblCheckbookEntry.Rows.Add(newRow); I want to get the identity of a column from that row I just added. How can I do this? Say the row is called ID. For reference, I'm using C# and sql server express. ...

SQL Server "Maximum Server Memory" - seems to have no effect on Virtual Size

On 32 bit windows xp, sql server express, I set SQL Server "Maximum Server Memory" to 200 MB, but as soon as I start it, in Sysinternals Process Explorer I still see Virtual Size consumed of 1.5 GB. Now I know this is no big deal if the Virtual Size is small, but when other applications max out the physical memory (Internet Explorer cou...

Inserting a dynamic number of rows into SQL Server

Is there a way to insert a dynamic number of rows from within sql server (.sql script) given the value of a look up, and setting one column for each insert? I want to attach a row with the foreign key of every row in a different table. For instance: table 1: 1 j k l m n 2-(fk) 2 j k l m n 3-(fk) 3 k u y k l 2-(fk) table 2: 2 hi you ...

How to specify MS Access workgroup file in Sql Server linked server?

I have an Sql Server database that includes a linked server to an MS Access mdb database. The Access database has workgroup security and requires a valid user name and password. This is easily set up in the linked server dialog in sql management studio. The problem is that the Sql Server needs to be able to find the MS Access mdw file to...

What are the good SQL Podcasts out there?

inspired by this question since i do not find any good sql casts out there and i fail to find any good ones to this day online. ...

Is it possible to automate SQL Server 2008 profiler?

There was a post regarding useful SQL tricks. Here I was going to mention the SQL Server Profiler tool, as it has helped me write less SQL. I would write SQL that would interrogate, understand or second guess the databases business logic. Profiler is very useful, especially where application code has embedded SQL and you want to work ...

Measuring Query Performance : "Execution Plan Query Cost" vs "Time Taken"

I'm trying to determine the relative performance of two different queries and have two ways of measuring this available to me: 1. Run both and time each query 2. Run both and get "Query Cost" from the actual execution plan Here is the code I run to time the queries... DBCC FREEPROCCACHE GO DBCC DROPCLEANBUFFERS GO DECLARE @start DATETI...

Can I use a store procedure output in an update statement in SQL Server?

Hi all, I'm converting some data in SQL Server 2005. I have a table update like this: update Invoices set Invoices.InvoiceReference = 'NewRef' where Invoices.InvoiceReference='Unknown' But what I'd like to plug in instead of 'NewRef' is the output from a stored procedure that uses parameters from the columns of the Invoices table. T...