sql-server

VB.Net (or C#) 2008 Multi Threaded Import

I am looking to build a multi-threaded text import facility (generally CSV into SQL Server 2005) and would like to do this in VB.NET but I am not against C#. I have VS 2008 trial and just dont know where to begin. Can anyone point me in the direction of where I can look at and play with the source of a VERY simple multi-threaded appli...

Client View of Everyone Looking at a Webpage

First let me say that I really feel directionless on this question. I am using windows integrated security, and I can use vb.net to look up information about a user from AD. I also have other information about users I can look up from a MS SQL 2005 server by getting the logon identity name. What I would like to do is display information...

How do you list all the primary keys of a table in SQL Server?

Simple question, how do you list all the primary keys of a table with T-SQL? I know how to get indexes on a table, but can't remember PK's. ...

How to insert multiple records and get the identity value?

I'm inserting multiple records into a table A from another table B. Is there a way to get the identity value of table A record and update table b record with out doing a cursor? Create Table A (id int identity, Fname nvarchar(50), Lname nvarchar(50)) Create Table B (Fname nvarchar(50), Lname nvarchar(50), NewId int) Insert into A(fnam...

How to determine size in bytes of a result set from LINQ to SQL

When writing manual SQL its pretty easy to estimate the size and shape of data returned by a query. I'm increasingly finding it hard to do this with LINQ to SQL queries. Sometimes I find WAY more data than I was expecting - which can really slow down a remote client that is accessing a database directly. I'd like to be able to run a que...

SQL server 2000 Like Statement Usage

I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used likes statements in the way I'm using them above. At first, I...

How can I tell how many SQL Connections I have open in a windows service?

I'm seeing some errors that would indicate a "connection leak". That is, connections that were not closed properly and the pool is running out. So, how do I go about instrumenting this to see exactly how many are open at a given time? ...

SQL Bulk import from CSV

I need to import a large CSV file into an SQL server. I'm using this : BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO problem is all my fields are surrounded by quotes (" ") so a row actually looks like : "1","","2","","so...

Experience with SQLExpress for a multi-user commercial application?

I have inherited a VB6/Access application that we have developed and sold for many years. We're going to SQL Server 2005 Express Edition and .Net. The application can be multi-user. Currently the setup is simple for the customer -- Navigate to the folder to create the database on first launch; second user browses to the same file. ...

Looking for a tutorial on SQL Server Reporting Services (SSRS)

where can i find the best tutorial about MS SQL server reporting services.. ...

SQL Server Service Broker

Were there any major or really cool features added to SQL Server Service Broker in 2008? ...

What exactly is SQL Server 2005 User Mapping?

In the new login dialog of the SQL Server 2005 Management Studio Express, what is the User Mapping actually doing? Am I restricting access to those databases that are checked? What if I check none? ...

Properly scoped transactions in Stored Procs

Suppose I have a stored procedure that manages its own transaction CREATE PROCEDURE theProc AS BEGIN BEGIN TRANSACTION -- do some stuff IF @ThereIsAProblem ROLLBACK TRANSACTION ELSE COMMIT TRANSACTION END If I call this proc from an existing transaction, the proc can ROLLBACK the external transaction. BEGIN TRANSACTI...

SQL Server: Is SELECTing a literal value faster than SELECTing a field?

I've seen some people use EXISTS (SELECT 1 FROM ...) rather than EXISTS (SELECT id FROM ...) as an optimization--rather than looking up and returning a value, SQL Server can simply return the literal it was given. Is SELECT(1) always faster? (I can imagine this making a difference if the field is a large VARCHAR, but is there a perform...

copying data from production to test server without erasing schema

Using sql server 2000, I would like to take my production data and put it in my test database, but I don't want to overwrite the schema of the test database as there are fields in it that I haven't added to production yet. Can this be done? I should add that these databases are on different servers. ...

Retrieving multiple rows into a listview control from an ODBC source works well for simple SELECTs with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query?

I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query (with two selects)? The most likely server will be MS SQL Server (probably 2005). The code is 'c' for the Win32 API. This code sets (wha...

Attaching an ID/Label to LINQ to SQL generated code?

I'm interested in tracing database calls made by LINQ to SQL back to the .NET code that generated the call. For instance, a DBA might have a concern that a particular cached execution plan is doing poorly. If for example a DBA were to tell a developer to address the following code... exec sp_executesql N'SELECT [t0].[CustomerID] FROM [d...

Force default value when adding column to table - SQL Server

In SQL Server 2000/2005, Is it possible to force the default value to be written to already existing rows when adding a new column to a table without using NOT NULL on the new column? ...

What is the SQL command to return the field names of a table?

Say I have a table called myTable. What is the SQL command to return all of the field names of this table? If the answer is database specific then I need SQL Server right now but would be interested in seeing the solution for other database systems as well. ...

SQL Server locks explained

Below is a list of locks that SQL Server 2000 is meant to support. I am a bit confused as to what the "intent" locks actually mean. I've looked around on the Web and the answers seem to be a bit cryptic. Further to getting an answer to my specific question, I am hoping to use this question as a Wiki for what each lock means and under w...