sql-server-2008

Best primary key format for large table

I'm developing an asp.net application that has some potentially large data tables. I would like to know what would be the best way to define a primary key. I know this has been asked before, but since this is for a specific situation, I think the question is valid. I'm using Entity Framework 4 on a SQL server 2008 database. What are th...

How does performance of guids compare to strings in sql

For primary keys on a large SQL Server 2008 data table, I have the choice of using guids or a string of about the same size. Performance-wise, how does a guid (16 bytes) compare to a string of about 16 chars, when doing joins, selects, etc. Is SQL better at handling guids because internally they are represented as a number? ...

Exporting and importing selected rows in a database

Let's say I have a database like this: Users ----- ID int PK Identity Name vchar(max) Sales ----- UserID int FK Description vchar(max) And some data: Users 1, "Daniel" 2, "Barnie" 3, "Frank" Sales 2, "New computer" 2, "Rubber duck" 3, "Cabbage" There are also several other tables that link to this primary key. Now there is a req...

How to save html table data to SQL Server 2008 Table Value

**http://www.dsebd.org/latest_PE_all2_08.php** above url contain a html table.I want to save this table value on XML and also want to save this table value on database MS2008. How to save html table values on database ...

LIKE function in SQL Server 2008 suggestion needed

I have a table Customer with 2 columns Name and Surname (sql Server 2008). User wants to search by Name-Surname - or just typing Jo Bloggs. Suppose a row is filled with CustomerId Name Surname 1 Jo Bloggs doing select * from customer where Name like '%Jo%' will find the records select * fr...

Simple SQL problem

I can't believe I'm getting so stuck on what seems like such a simple query. I need to get back the User of a Log for a given Project which has the maximum DateLogged value. I've rewritten it a million ways but this is the way which expresses what I want the clearest - SELECT L.User FROM Log AS L WHERE L.Id = 24 GROUP BY L.ProjectId HA...

divide sql server table int chunks

using sql server 2008 I would like to take a table that has 11 million records and divide them into chunks of 50000 each while maintaining the original table and just making sure each chunk contains unique records. If I select top 50000 records for the first batch, how can I guarantee I get the next 50000 and so on. ...

Grouping parents containing the same set of children

I have this parent-child relationship Paragraph --------- ParagraphID PK // other attributes ... Sentence -------- SentenceID PK ParagraphID FK -> Paragraph.ParagraphID Text nvarchar(4000) Offset int Score int // other attributes ... I'd like to find paragraphs that are equivalent; that is paragraphs tha...

Advice on how to modernize SQLXML 3.0 application

I'm hoping you can help me narrow my research on how to "modernize" my use of SQL XML... I recently "dusted off" a bit of something I cobbled together several years ago. It utilizes something called SQLXML 3.0 and IIS Virtual Directory Management for SQLXML 3.0 resulting in an XML template that contains a SQL EXECUTE of a stored procedu...

Using double-quotes in a SQLCMD query

I'd like to issue the following command through SQLCMD: IF DB_ID('My_DB') IS NOT NULL DROP DATABASE My_DB There are a few caveats though... The database name is dynamic The program which is running the command (BuildForge) will not replace a variable if it appears within single quotes So, I can't use: -Q"IF DB_ID('${db_name}') IS...

Procedures using IDENTITY column fail with primary key violation after restoring sql 2000 backup onto sql 2008

I've just moved a database from a SQL 2000 instance to a SQL 2008 instance and have encountered an odd problem which appears to be related to IDENTITY columns and stored procedures. I have a number of stored procedures in the database along the lines of this create procedure usp_add_something @somethingId int, @somethingName nvarchar(1...

Build output files have the db name prepended to them; don't want that.

I have STFW, the documentation, and poured through my own build scripts and cannot find the answer; even reading through a "Diagnostic" build log has yet to reveal what I am looking for. When I build a VS2010 / MSSQL 2008 solution containing four projects, the output for each project looks like: __target/$Arch_$Config/sql/$projectName/...

t-sql combine column values

Based on the following table ID Description ReleateID ----------------------------------- 1 some desc1. 50 1 some desc1. 60 2 some desc2. 50 2 some desc2. 70 3 some desc3. 80 How to get the following output ID Description AllRelatedIDs ---------------------------------- 1 some desc1. 50,60 2 some desc2...

Can I set the isolation level in the connection string?

How can I set the isolation level of all my SqlCommand ExecuteNonQuery calls to be read uncommitted? (connecting to a SQL Server 2008 enterprise instance) I am simply transforming static data and inserting the results to my own tables on a regular basis, and would like to avoid writing more code than necessary. ...

XQuery if exists conditional insert / replace

What would the XQuery look like to check if a node exists, and if it does then run a replace statement, if not then an insert statement? Here's what I have in mind. I want to store whether or not a user has read an important message in XML. Here's what the data would look like. <usersettings> <message haveRead="0" messageId="23" ><...

How to save in database

http://www.dsebd.org/latest_PE_all2_08.php above url contain information want to save is database ms2008. How to save this value . ...

Timing compare in SQL Server 2008

Hi All. How to compare Indian time with world's other country times in SQL Server 2008? Means i want to know if in India its mid night 1 am what will be timing in other countries through SQL Server 2008 ...

Setting up 2 factor authentication

Hi We are in the process of building a new website which we want to lock down to specific computers to only allow access, then once the pc is authenticated we will do our in built user authentication. Also, when a pc is known, we dont really want anything on the pc which can be easily transfered (by the client) onto another pc in order...

Filtered index in SQL Server 2008

Hi I have created filtered unique index in one my database table. According to my research if i want to do any operation on that table from asp.net i need to turn on the following set operation to my connection SET CONCAT_NULL_YIELDS_NULL ON SET ANSI_PADDING ON SET ANSI_WARNINGS ON If i turn the above features, what will be the effec...

Debugging a SQL Query

Does SQL Server 2008 have a built in debugger? I've got a stored procedure that returns an error if it is fed a string of alphabetic characters (as opposed to numeric) and I'd like to be able to determine what line it gets to before returning an error. ...