Questions for sql-server


8877

“Violation of PRIMARY KEY constraint” when Inserting

I'm getting the above error when running an insert into on one of our tables.
9160

How to trim leading single quote and leading zeros from sql query

I need to compare two columns in a sql table. The data in one column has a leading single quote and may have leading zeros and the other column may have leading zeros. I need to trim the leading ze...
1782

Transaction locking in Sql Server

We have an old version of Cognos 7 running on Sql Server 2000 Enterprise.
743

Login failed for user 'someone'

I work on Microsoft SQL Server 2008 R1 and visual studio 2010.
5719

How much space does a view take up in Microsoft SQL Server

I have a very large table in SQL Server 2008. It has lots of fields which are only useful to a certain segment of users, some of the fields some users shouldn't be able to see.
881

SQL Backups in Compressed Folder

We are looking for a free solution to compress our SQL Server backups for SQL Server 2005. I am aware of SQL Safe freeware edition, but I was wondering what others thought of storing backup files in
1703

How to refactor PHP to help improve SQL Server speed?

I've been tasked with finding a solution to some performance issues we've been having with our PHP web application (basically, we're reaching a "failure" point when combining high-volume users with...
1664

How to choose returned column name in a SELECT FOR XML query?

MS SQL has a convenient workaround for concatenating a column value from multiple rows into one value:
3302

Using SQL, how do I update rows, using their own values?

I have the following table which I'll call 'example'
7337

Removing tables with a join in SQL Server

I'm new to this DBA thing and I've been tasked with removing duplicates from a couple of tables. I'm working in SQL Server. They all have a field called LAST_UPD that tracks their last update. A...
4493

DB connection strings in MVC applications using Entity Framework

I am working on an MVC application using Entity Framework.
758

Convert SQL DateTime format

How can I display a DATETIME value (2010-12-02 15:20:17.000) as 02/12-2010 15:20?
9986

How to make SQL Server running in Virtual PC accessible to host OS?

I'm running SQL Server 2008 Express on Windows XP on a VirtualPC instance inside a Windows XP host. I want to be able to connect to databases on the guest instance using SSMS on the host. When I ...
4411

SQL Server 2008 R2 Distributor on Subscriber for Reporting DB?

I have to setup a database for reporting, and I chose transactional replication for that because it seems the easiest way (setup has to be easy, i will have to explain to customers how to do that)....
7061

How to move a sql server express mdf file to a different sql sever express server?

I'm trying to move my database.mdf file from a development environment to a SQL Server Express server that is hosted on my VPS - but I can't figure out how to attach the file to my database server....
3565

Unable to cast TEXT to XML in SQL Server

Basically I have a column named XML that is of type TEXT; this cannot be changed for other reason, but I was wondering how I could cast it to XML.
7704

SQL Server Database File and WCF

I have a WCF Service that exposes a method GetCustomers(). The internals of the method uses a Data Layer along with a Business Layer to return a List of Customers. Currently I am using an SQL Server
1073
349

SQL Server Insert query for a forum

Considering a forum table and many users simultaneously inserting messages into it, how safe is this transaction?
9840

formatting sql server PRINT messages?

I have the following Print statement which print some details but it is not tabbed properly and looks awful. is there any way i could print them in tabbed format so they all meet at the same place ...
6120

Force SQL Server to respond slowly in order to test client application response to timeout

Is it possible to somehow force Microsoft SQL Server to slow down certain or all queries so that we can test the client application on how it acts when the SQL queries run for extended time? For ex...
4053

mssql table multi foreign key cascade

I'm confident that this is possible but for the life of me I can't figure it out.
8164

Checking for Constraint

I need to write a SQL script to ensure that a constraint is existing.
4593

SQL and XML - Calculation of longest continuous pause

I have a very specific problem which i was hoping somebody could shed some light on. It is not exactly an error but more so help on the query i need to run to return the desired result set.
9697

Why is my new schema not showing in the table properites pane?

I am using SQL Server 2008 Express and Sql Server Management Studio 2008.
3860

How do I get “select for xml” to output to several files?

Our customer is complaining that our export file is too long; they would like us to split the export into many files with no more than “n” records per file. Is there a way of doing this with “sele...
4924

Bulk Insert Data Type Mismatch in datetime

In My Bulk Insert Query i have one of the column in .LST file as |12083121022612| Format of this column is as "YYMMDDHHMMSSTT" In dbo.ReportMain Table i have set Data Type for this as datetime
7435

inner join and group by

I have two tables with identical definition.
5340

How do I perform an exact string match on a non-case sensitive field?

I would like to find all the rows in a table and match on an exact case sensitive string. Unfortunately, my table has the case insensitive collation.
9183

Alter Table Alter Column failing for resizing columns

ALTER TABLE TABLE_NAME ALTER COLUMN COLUMN_NAME
5553

Reduce deadlock on PAGE level on update query on MS SQL

I have some funny deadlock caused by a stupid simple SQL UPDATE query, on a flat plain table, under default "READ COMMITED" transaction.
3311

How to create index in SQL from c#

The scenario is as follows. I need to drop a particular index at the beginning of the C# application. After all the insert sql statements which are part of processing are complete, I need to creat...
3186

Cursor loop is not working. Only taking last value in parameter?

I created stored proc so that user can select multiple comma separated values into single parameter.
3986

Entity Framework SQL Server increments an Id Key out of order if previous values are available

I have an MVC4 website and it has a SQL Server DB that contains its posts. On each post there is a Next and Previous button. These buttons are calculated from databaseContext.Post.Count() plus or m...
9219

Search Entire Database To find extended ascii codes in sql

We have issues with extended ascii codes getting in our database (128-155)
1441

Using WITH NOLOCK Table Hint in Query Using View - Does it Propagate Within the View?

If a "WITH NOLOCK" query hint is used on a View in SQL Server, does it propagate that hint to the view definition itself, even if NOLOCK is NOT used for the raw tables in the View definition? The r...
7564

datatype supplied by user for SQL field

I have a SQL table which has a number of fields
7927

Ignoring accents in SQL Server using LINQ to SQL

How can I ignore accents (like ´, `, ~) in queries made to a SQL Server database using LINQ to SQL?
7139

Multi-bit database field

I'm using a MSSQL database and would like to create a column that only has 4 possible values. Is there any way to define a 2-bit column? I see the bit datatype and then the next smallest is tin...
4137

SQL Check Constraint on Table Columns

I have the following check constraint to add to an existing table.
6078

User-Defined Functions SQL Server 2005 flagged incorrectly as non-deterministic?

Related to this question, I decided to check the UDFs in my data warehouse (which should largely have been deterministic), and I found several which aren't which should be.
1295

Sql iteration over XML

I'm trying to read xml data field from a table and insert this data in another database. The XML document looks like this:
3447

Getting next matching string value from a SQL table

My SQL table have a column name AddressName . I am storing customer address name in that column. And I want to store them in the following format, suppose when I inserted first time a value in that
8195

Escaping function wiping all data from text fields/areas

I am attempting to replace ' with '' for error reasons within MSSQL queries. I understand that it could be more secure, I am just learning and they will get more secure.
1071

What's your approach for optimizing large tables (+1M rows) on SQL Server?

I'm importing Brazilian stock market data to a SQL Server database. Right now I have a table with price information from three kind of assets: stocks, options and forwards. I'm still in 2006 data a...
6050

Setting and resetting the DATEFORMAT in SQLServer 2005

Is there a way to query the current DATEFOMRAT SQLServer 2005 is currently using with T-SQL?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.