sql-server

MS Access vs SQL Server and others ? Is it worth taking a db server when less than 2 Gb and only 20 users

After my experiment with MSAccess vs MySQL which shows MS Access hugely overperforming Mysql odbc insert by a factor 1000% before I would do the same experiment with SQL Server I searched for some other's people and found this one: http://blog.nkadesign.com/2009/access-vs-sql-server-some-stats-part-1/ which says "As a side note, in th...

How to select 'previous' and 'next' records in SQL?

I am building a blog-post detail page on my site that will display display a 'previous' and 'next' link similar to how a typepad blog post works. See example below. I am wondering if there is a way to query the database which accomplishes something like the image below where it selects the 'current' record (in yellow) for display, but ...

Insert data into SQL server with best performance

I have an application which intensively uses DB (SQL Server). As it must have high performance I would like to know the fastest way to insert record into DB.Fastest from the standpoint of execution time. What should I use ? As I know the fastest way is to create stored procedure and to call it from code (ADO.NET). Please let me know ...

Convert date in text format to datetime format in T-SQL

I have a client supplied file that is loaded in to our SQL Server database. This file contains text based date values i.e. (05102010) and I need to read them from a db column and convert them to a normal date time value = '2010-05-10 00:00:00.000' as part of a clean-up process. Any guidance would be greatly appreciated. ...

Adding to the schema of a subscribing database.

Transactional Replication on SQL Server 2005 Enterprise x64 (SP3). I need to add check constraints to a databases that is the target for a replication, but I cannot add the check constraints to the publishing database. The Problem is that the replication process keeps removing my constraints. How do I prevent this? ...

server client iphone with json

I am trying to make a server client app for iphone and I am using json. I want to load and store some text and some images to my sql server. I was able to get the text from my server but not the images and I have not figured out how to post things to my server.Am I in the right track here or should I start using xml. Can anybody help me?...

Login failed for user 'DOMAIN\MACHINENAME$'

I know this is almost duplicate of : http://stackoverflow.com/questions/1269706/the-error-login-failed-for-user-nt-authority-iusr-in-asp-net-and-sql-server-2 and http://stackoverflow.com/questions/97594/login-failed-for-user-username-system-data-sqlclient-sqlexception-with-linq-i but some things don't add up compared to other appliations...

Hibernate duplicate primary key on restart using GenerationType.TABLE

We're running into an issue where we have Event subclasses that use GenerationType.TABLE to generate the primary key, and when we restart the servers we are getting duplicate primary key errors. We're using SQL Server and Hibernate version 3.5.1-Final. Here's what our Hibernate annotations look like: @Entity @Inheritance(strategy = In...

How to order by column with non-null values first in sql

I need to write a sql statement to select all users ordered by lastname, firstname. This is the part I know how to do :) What I don't know how to do is to order by non-null values first. Right now I get this: null, null null, null p1Last, p1First p2Last, p2First etc I need to get: p1Last, p1First p2Last, p2First null, null null,...

Question about Reporting and Data Warehousing Software bundled with SQL Server 2005

We currently use SQL Server 2005 Enterprise for our fairly large application, that has its roots in pre SQL Server 7.0. The tables are normalized and designed mainly for the application. The developers for the most part have the legacy SQL Server mindset. Only using the part of TSQL that existed back in 7.0, not using any of the new f...

I need to insert multiple rows at once in sql server ..based on an iterative value

Hi friends, I want to insert 3 rows at a time in a table based on select statement.. consider the query insert into tblTemp ( a,b ) select a, b from tblTemp2 This lets me insert one row in tblTemp.. my requirement is to add 3 rows with iterative values a,a+1,a+2 for each b inserted. ...

SQL Query problem: How to merge two lists.

I have a base table of Participants and Answers, with the following structure: ParticipantId, BusUnitId, QuestionNum, Answer. In this table, QuestionNum ranges, say, from 1 to 6. I also have two other tables that sort of link QuestionNum to the actual question table, BusUnitQuestions, and ParticipantQuestions. For each QuestionNum, ...

Stored proc executes >30 secs when called from website, but <1 sec when called from ssms

I have a stored procedure that is called by a website to display data. Today the web page has started timing out so I got profiler going and saw the query that was taking too long. I then ran the same query in management studio, under the same user login, and it takes less than a second to return. Is there anything obvious that could be...

What does xp_qv do in SQL Server?

Last night one of our SQL servers developed some major problems and after a colleague stopped, started, and all the usual things it started checking and rebuilding databases and is now running an extended stored procedure called "xp_qv". The internet seems to be very short of information on what this procedure does or anythign like that...

How do you search between two columns using a parameter and a case when statement? SQL Server

I would like to search between to columns in a s query or a table depending on the variable on a paramenter e.g Declare @SelectAll as interger Set @SelectAll = 1 Declare @Column as interger Select mt.Column1, mtColumn2 From MyTable as mt Where Case When @SelectAll = 1 Then mt.Column1 IN(@Column) and mt.Column2 (' Selecting...

Multiple Language (English, Dutch, Finnish, French, Hungarian, Bangla, Italian,) in ASP.NET with SQL server !

I am developing a web Application in ASP.NET 3.5 with SQL Server 2008. I need Multiple Language such as English, Dutch, Finnish etc. I can do it by using System.Resources and System.Globalization. but I can't convert the Language which data come from database. How can I solve it ??? ...

Logging into table in SQL Server trigger

I am coding SQL Server 2005 trigger. I want to make some logging during trigger execution, using INSERT statement into my log table. When there occurs error during execution, I want to raise error and cancel action that cause trigger execution, but not to lose log records. What is the best way to achieve this? Now my trigger logs everyt...

Question on different ways to link tables

What is the difference between linking two tables and then the PK is an FK in the other table, but the FK has not got the primary key option (so it does not have the gold key), and having the PK in one table as a PK in another table? Am I right to think that the second option is for a many-to-many relationship? Thanks ...

sp_helptext output being dropped by ADO.NET ?

Hi all, I'm using the tool described here to clean up some cruft from our development DBs. I've encountered an odd issue with it and can't find the cause. For certain stored procedures, the GetProcedureText method (l:47, Validator.cs) fails to return the proc text, causing the program to behave unexpectedly. When debugging and stepping...

Index for wildcard match of end of string

I have a table of phone numbers, storing the phone number as varchar(20). I have a requirement to implement searching of both entire numbers, but also on only the last part of the number, so a typical query will be: SELECT * FROM PhoneNumbers WHERE Number LIKE '%1234' How can I put an index on the Number column to make those searchs e...