sql-server

Sql Reporting Services Parameter Question

I'm new with SQL Reporting Services 2008 and cannot find out how to do something that should be simple. What I have is a single select parameter that is populated with a list of salesman from a query. This works great. And I have the dataset query responding to this parameter working well. So my reports for a single salesman are work...

The most efficient way to get all data from SQL Server table with varchar(max) column.

This question is for SQL Server 2005. I have a table with 2 columns. Table_A Id Guid (PrimaryKey) TextContent varchar(max) The table contains around 7000 records and textcontent range from 0 - 150K+. When I do a select statement SELECT Id, TextContent FROM Table_A, it took a very long time around 10 minutes. Is there a...

Get first Sunday of next month using T-SQL

Looking for a way to get the date in the format "11/1/2009", which would be the first sunday of next month. I want to run this query after the first sunday in october to get the first sunday of the upcoming month. What is the best method to accomplish this with a T-SQL query? Thanks ...

Find All References to View

I've got various databases, and what to be sure I am removing something (a view in this case) that is truly orphaned. Is the the correct SQL to be using: SELECT r.routine_name, r.routine_definition FROM INFORMATION_SCHEMA.ROUTINES r WHERE r.routine_definition LIKE '%my_view_name%' The problem with it is that these referenc...

Venue/Event Booking Database Design

I am task with designing a database for online bookings. I am not looking for a full design as we have had previous exp with online house rental. What i would like to know, is how do we design a db for booking of hotel, travel, events. We have some ideas. Basics... Have all venues/ events (once/reoccuring) register. That seems like ...

How can I compare two variables/columns of type NTEXT

I know I can convert the variables to nvarchar(max) first and then compare with the = or <> operators. But is this the right way? ...

T-SQL Query Returning Items It Shouldn't Be.

Here's the scenario. The column in question is called 'datein' and it's type is 'datetime'. I have three rows with the value of '2009-10-01 00:00:00.000' for 'datein'. Why does this query return the aforementioned rows? SELECT * FROM t_call AS tc WHERE tc.datein >= '2009-09-30 00:00:00.000' AND tc.datein <= '2009-09-30 ...

atomic compare and swap in a database

Hello: I am working on a work queueing solution. I want to query a given row in the database, where a status column has a specific value, modify that value and return the row, and I want to do it atomically, so that no other query will see it: begin transaction select * from table where pk = x and status = y update table set status ...

How to get individual identity in an XML Insert?

I haven't worked much with XML in SQL so I'll try to ask the question the best I can. Say I receive some structured XML in SQL for insertion. The structure might be: <Team> <Player> <Name>Player1</Name> <Games> <Game> <Date>9/7/2009</Date> <MinutesPlayed>90</MinutesPlayed> </Game> </Ga...

SQL Server 2005 Transactions

I have a long running stored proc (approx 30 mins) which is currently running within a transaction (isolation level snapshot). I've set the transaction to snapshot to avoid locking records preventing other processes from accessing the data. What I'm trying to do is write to and read from a status table, but although we're in a transacti...

Email Synching into Custom App

Hello, How have people intergrated custom CRM type applications with email? I have a Access 2003 front-end application with a SQL Server 2005 backend. One CRM part of the application tracks the activity with the customer in a traffic log table. Sometimes the salesstaff has communication with their customer using email instead. What...

How to update running balance in one shot?

I have a temp table, let's call it #invoices, defined as create table (id int identity(1, 1), billed money, credited money, balance money) i have the following data in it Billed Credited 140.00 20.00 60.00 20.00 -20.00 I would like to update the balance column with the running balance. so that the...

Streaming Databased Images Using HttpHandler

For a long time now I have noticed something annoying when working on Web Application projects involving databased images on my local machine. By local I mean that it's a typical environment with VS 2008 and SQL Server 2005 on my workstation. Whenever I use an HttpHandler to display the images on my local, only a portion of the images re...

'Simple' SQL Search query

Ok, so I'm working on a basic search SPROC. One of the Parameters is a search text (this will be the test the user enters in, words separated by spaces etc.) Now all I need is to search these words on a single column in a table, BUT I want it to have ALL the keywords that were entered (at the moment all I can do is if 1 of them is there...

SQL Server "Shared Memory provider" Error

Hi, I am running the following command in a batch file: osql -S dbname -U username -P password -i C:\inputSQL.sql -o C:\postMigration.log -n The dbname, username, and password have all been set correctly. However , when I run the batch file I get this output to the "C:\postMigration.log" log [SQL Native Client]Shared Memory Provid...

Reporting Services Folder Configuration

As a Newbie for Reporting Services, I have some confusion about setting up report services on my local dev machine. I'm using Sql-Server 2008 Developer Edition on Vista64 Home Premium. When I go to http://localhost/reports, I'm being asked for a login. When I enter an account that I have configured to be a local admin, I get to minima...

How do I keep a table synchronized with a query in SQL Server - ETL?

I wan't sure how to word this question so I'll try and explain. I have a third-party database on SQL Server 2005. I have another SQL Server 2008, which I want to "publish" some of the data in the third-party database too. This database I shall then use as the back-end for a portal and reporting services - it shall be the data warehouse. ...

SQL - What type of join is it and the best way to rewrite?

Our 3rd Party app has a custom View with the following: FROM dbo.vwPositionAssetSubWeight INNER JOIN dbo.vwPositionAssetSubTotal ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetSubTotal.AssetID FULL OUTER JOIN dbo.vwPositionAssetPendingTrades ON dbo.vwPositionAssetSubWeight.AssetID = dbo.vwPositionAssetPendingTr...

How to make total?

Using SQLSERVER 2000 How to make a total of intime value Table 1 InTime 02:00:48 22:00:22 ....., Intime Datatype is varchar 02:00:12 - (HH:MM:SS) Before I tried in access 2003 select format( Int(24*sum(Intime)), '0') & format( sum(Intime) , ':ss' ) AS totaltime from table1 Above Query is working perfectly in Access 2003 How to...

SQL query slow from .NET code, but not interactively

We are using an ORM that is executing a call from .NET to SQL Server's sp_executesql stored procedure. When the stored proc is called from .NET, we receive a timeout exception. Looking at Profiler, I can see that the query is indeed taking a long time to execute. The query is essentially: exec sp_executesql N'SELECT DISTINCT FROM [Ou...