sql-server-2005

Enforce query restrictions

I'm building my own clone of http://statoverflow.com/sandbox (using the free controls provided to 10K users from Telerik). I have a proof of concept available I can use locally, but before I open it up to others I need to lock it down some more. Currently I run everything through a stored procedure that looks something like this: CREA...

SQL Server 2005 express edition - stored procedure for search my table

I have table which have columns with values and null values. i need to write a stored procedure to search rows of my table.but these null value columns do not produce an out put... it gives me a result like this Type Value Int32 0 ...

vs.php remote database connection

Hi, I'm currently using vs.php on a development client. (vs.php is a php dev IDE that uses the visual studio shell). The problem is connecting to our remote sql 2005 database. The connectionattempt fails in less than 1 seconds. I can connect to the database with telnet without problem from the same client. The database is set to allow...

SQL Server 2005 "FOR XML PATH" Grouping

I'm trying to generate a XML document from the SQL Server 2005 database by using "FOR XML" construct. There are two simple tables in the database with a one-to-many relationship: 1) Magazines | Id | Number | Name | ---------------------------- | 53 | 0001 | Magazine 1 | | 54 | 0002 | Magazine 2 | | 55 | 0003 | Magazi...

How to bulk insert into a table in sql server 2005

Hi all, I have a storedproc which takes an ntext field where some records are passed. Suppose there is a table t as below. | ID | Name | Designation| -------------------------- | 1 | ABC | Team leader| | 2 | DEF | Developer | | 3 | XYZ | Manager | I am sending two more record as '4|Tom|Developer; 5|John|Team Leader;' The ab...

Trace in SQL Server 2005 Mobile Edition

Is there any tool available, from Microsoft or 3rd party, that allows a trace to be performed on Windows Mobile 6 device running Microsoft SQL Server 2005 Mobile Edition? ...

Can I install Sql Server 2008 on the same machine where Sql Server 2005 already installed.

I have Sql Server 2005 Express installed on my computer, and I want to install Sql Server 2008 Express as well. What should I consider before doing this additional installation? thanks. bk ...

SQL Server 2005 Deadlock Problem

I’m running into a deadlock problem when trying to lock some records so that no process (Windows service) picks the items to service them, then update the status and then return a recordset. Can you please let me know why am I getting the deadlock issue when this proc is invoked? CREATE PROCEDURE [dbo].[sp_LoadEventsTemp] ( @Request...

VS 2008 Generate Create Script to Project Fails

When I try to run Generate Create Script to Project on a table in the Server Explorer, I get the following error—An error occurred during the operation: The Table '[dbo].[TableName]' cannot be scripted as its data is not accessible. I can view the table data without any problem. I have generated several create scripts from the same data...

tsql script to find tables not being used by stored procedures, views, functions, etc?

Is there a t-sql script to find out tables that aren't being used in sql server by stored procudures, views, functions, etc. I have a database that has 100s of tables, if not more and before I go dropping tables, I wanted to know if there was a script that could go through each object in the database and tell me if any tables are in use...

Are single statement UPDATES atomic, regardless of the isolation level? (SQL Server 2005)

In an app, Users and Cases have a many-to-many relationship. Users pull their list of Cases often, Users can update a single case at a time (a 1-10 second operation, requiring more than one UPDATE). Under READCOMMITTED, any in-use Case would block all associated Users from pulling their list of Cases. Also, the most recent data is a h...

sql 2005 profiler analysis

we have some performance issue with a program, I traced tsql using sql server 2005 profiler and find below result for an INSERT statement, cpu: 0 read: 28 write: 0 duration: 32804 I guess it's because the inserted table has several indexes and it's getting big. is there any other possibilities that I should check? thanks. ...

Return a recordset from a SQL CLR Assembly?

Guys lease help me out I think I'm close, but I'm missing something. Background I'm rewriting a SQL CLR assembly (stored procedure), my assembly contacts another resource and gets back XML. I want to return this XML as a recordset, NOT a scalar value. From what I've seen, this is how to return a recordset: SqlContext.Pipe.Send(mySqlD...

SQL 2005 MD5 Hash and C# MD5 Hash

I currently have a legacy database (SQL 2005) that generates hash strings for tokens. It does it like this... DECLARE @RowID INT DECLARE @hashString VARCHAR(128) SET @RowID = 12345 SET @salt= 0xD2779428A5328AF9 SET @hashBinary = HASHBYTES(('MD5', @salt + CAST(@RowID AS VARBINARY(30))) SET @hashString = sys.fn_varbintohexstr(@hashBina...

Conditionally create a fulltext catalog in one line of SQL (from an installer)

I'm building an installer using WiX (not keyworded since WiX is not the problem here) that shall create a fulltext index for a SQL Server Express 2005 Advanced Services database. Up to now I use the SQL CREATE FULLTEXT CATALOG Foobar in path 'c:\Whereever' Now, the installer will not remove the database on uninstall as it may contai...

Data from 4 different database

I need to get data from 3 different databases on one event command. Can anybody tell me any efficient way besides I am querying to all three different database servers in a row:- Server 1 : Select * from .... Server 2 : Select * from..... and so on... Thanks very much ...

Complicated SQL query

I have the following db tables (which is simplified to illustrate the problem) CampaignTx campaignTx_id | member_id | date_created | shop_id 1 | 2 | 7/12/2009 | 2 2 | 4 | 7/13/2009 | 3 3 | 6 | 7/14/2009 | 4 4 | 5 | 8/14/2009 | 3 5 | 10| 8/19/2009 | 1 Reliability Reliability_id | campaignTx_id | status 1 | 3 | 0 2 | 2 | 1 3 | 4 |...

"Indexing" (aka maintaining a table of) aggregate data in SQL Server 2005

I have a table which maintains performance data of a system, each record is a call made to some important method and consists of the method name, its duration and a token - each request to the system is given a unique token and so all of the records with the same token are the same request, e.g: CallName Duration Token -----------...

Set Maximum Value for an Identity Column in SQL SERVER 2005

Hi all, I am developing an Windows pplication(using Visual Studio 2008,Sql server 2005). I have to maintain userlog information. I am having an identity column. It is working fine. But now the value of identity column is 172. Again when I try to log on I am getting the error as: Violation of Primarykey pk_userLogId cannot insert duplic...

Retrieving rows with the highest value

I have this query which returns all rows from a table: select Cost, Name, Id from #Table It returns a result set that looks like this: Cost Name Id ---- ---- ---- -2.00 Item1 1 4.00 Item2 1 6.00 Item3 1 3.00 Item1 2 9.00 Item4 2 What I want to do is grab a row from each ID with the highest value, so the 5 ...