sql-server

SQL query in SQL SERVER 2005 - Comparing Dates

I'm having a hard time doing this query. I want to compare dates in my query, dates from my DB are in this format: (MM/DD/YYYY HH:MM:SS AM) I want to compare this date with tomorrow's day, today plus one. My questions are: How do I declare tomorrow's date in sql server? How would you compare these two dates? Thank you!! =D EDIT : DATE...

How to generate a RNGCryptoServiceProvider-like number in TSQL

Does anyone know of a way to generate a RNGCryptoServiceProvider-like random number in T-SQL without having to register any .NET Assemblies? ...

SQL Server - Storing linebreaks in XML data type

Is it possible to store non-alphanumeric characters (more specifically line break characters) in a XML data type? The code below illustrates my problem: declare @a xml declare @b nvarchar(max) set @b = '<Entry Attrib="1'+CHAR(13)+'2" />' print @b set @a=convert(xml,@b,1) set @b=convert(nvarchar, @a,1) print @b The output is: <E...

What is the fastest way to delete massive numbers of records in SQL?

Possible Duplicate: What is the best way to delete a large number of records in t-sql? What is the fastest way to delete massive numbers (billions) of records in SQL? I want to delete all the records that match a simple rule like myFlag = 3. Is it possible to add a WHERE clause to a TRUNCATE? Another solution that could be po...

SQL Profiler not connecting to my server

My SQL Profiler was working previously against my Server. I have not (AFAIK) made any modifications to the configuration of my server. When I go into SQL Profiler I attempt to "Connect to SQL Server", I enter my SQL Server (which is on my local dev machine), I get the error To connect to this server you must use SQL Server Managemen...

Questions about Sql Server 2008 FullText Search

I'm using Sql Server 2008 FullText Search for a project. I need to be able to search PDf files, and I had some questions relating to that: How do I enable PDF searching? I've heard of the adobe filter, but couldn't find a clear guide on how to get started. Are the PDF files stored in the DB itself, or in the file system? I was mainly...

Is WHERE ID IN (1, 2, 3, 4, 5, ...) the most efficient?

I know that this topic has been beaten to death, but it seems that many articles on the Internet are often looking for the most elegant way instead of the most efficient way how to solve it. Here is the problem. We are building an application where one of the common database querys will involve manipulation (SELECT’s and UPDATE’s) based ...

SQL Server Express 2008 redundancy

Does anyone know what my options are for redundancy using SQL Server 2008 Express edition. I'm looking to have 2 DB servers running the express edition. ...

Pivoting in T-SQL based on date offset

There is a table called Orders has three columns: OrderID UserID OrderDate I need to know, for X months in the past, A users placed 1 order, B users placed 2 orders, C users placed 3 orders, etc. So the output is a table w/ a MinDate field and then columns for each # of orders from 1 to N, e.g.: declare @t table ( MinDate dateti...

Installing SQL Server Express 2008 side-by-side with VS2008 and SQL Server Express 2005

Is it possible to install SQL Server Express 2008 when I have VS2008, SQL Server Express 2005 and SSMS 2005 Express installed? Furthermore, is it possible from VS2008 to assign SQL S.E. 2005 to one project and for another project assign SQL S.E. 2008 to be used? I am working on a project where we use SQL S.E. 2005, but I am following s...

Call a Sproc on another SQL Server without being linked via TSQL

I want to call a sproc on server B from server A in TSQL without linking the servers. Is it possible to use something like a connection string to execute this sproc? The return will be a single nvarchar value. Regards. ...

Enforcing effective dated records in sql

Suppose I have a record with a column called "Name". Each record can be effective dated, so I also have an effective date and an expiry date column. The "Name" column has to be unique, but only within overlapping periods of the effective date and expiry date. I'm looking for some sort of efficient way to enforce this from within the s...

Performance: PHP and MS SQL Server: SQLCMD using Exec or Driver

Hello all, I am currrently making queries to my SQL Server using SQLCMD and I run this from PHPs exec() function. I was hoping to clarify that this isn't as efficient as the driver for SQL Server for PHP: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx. I am not sure if this is the same as http://us3.php.net/manual/en/book...

MS Access error "ODBC--call failed. Invalid character value for cast specification (#0)"

Does anyone have an idea what this error means or how to solve it? I am using Access 2003 and SQL2005. It comes up when trying to add a record on a particular subform. [Microsoft][SQL Native Client] Invalid character value for cast specification (#0) This MS bug report describes the same message, but it is a bug in SQL Server 6.5 that...

Asp.net chat application using database for message queue

Hello, I have developed a chat web application which uses a SqlServer database for exchaning messages. all clients poll every x seconds to check for new messages. it is obvious that this approach consumes many resources, and I was wondering if there is a "cheaper" way of doing that. I use the same approach for "presence": checking wh...

SSRS - How to check all rows in a table?

I have a table in a report and a textbox that changes its background color based on the value(s) in the table. Right now I have the background color expression for the textbox set to: =iif(Me.Value = ReportItems![NewValue].Value, "Yellow", "Transparent") "NewValue" is the name of one of the columns in the table. The above works fine ...

Is there a compact or express SQL Server version that I can package with my WinForms app & is free?

Hi, Is there a light weight version of SQL Server I could use that has the characteristics of: Free (assuming my winforms app is semi-commercial) Can be seemlessly packaged for deployment as part of the winforms click-once application? (i.e. ease in installation for the user). Light weight for the user (ideally something that just ru...

SQL Server 2005: Internal Query Processor Error:

I am trying to execute this following procedure in SQL Server 2005. I was able to execute this in my development server and when i tried to use this in the Live Server I am getting an Error "Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services". am usi...

Getting Wrong Total output?

Example I want to calculate the worktime between 09:00:00 to 18:00:00, 09:00:00 - Normal_Intime 18:00:00 - Normal_Outtime Suppose 1) Intime is 10:00:00, Outtime is 17:00:00 It should give the output as 07:00:00 2) Intime is 08:00:00. Outtime is 19:00:00 It should give the output as 09:00:00 above output should compare with Normal_...

How to make a SQL looping for date?

select CAST(convert(varchar, a.rechargedate, 112) as datetime)as RechargeDate, COUNT(distinct a.mobileno) AS UnitTotal, SUM(a.amount) AS AmountTotal from recharge a where *a.rechargedate BETWEEN '2009-07-01' AND '2009-07-31'* group by CAST(convert(varchar, a.rechargedate, 112) as datetime) order by a.rechargedate above is my sql query....