sql-server

How to keep an audit/history of changes to the table

I've been asked to create a simple DataGrid-style application to edit a single table of a database, and that's easy enough. But part of the request is to create an audit trail of changes made, who made them, and the date/time. How might you solve this kind of thing? (I'll be using C# in VS2008, ADO.NET connected to SQL Server 2005, WPF...

Using SQL Server 2008 Standard to initially start out a .com

I know Enterprise is what I really want but when you have NO budget practically and want to start a .com then I wonder if standard would be a good choice to go with initially until you're pushed by sheer volume to go to Enterprise later with SQL Server 2008. Thoughts? I can't afford Enterprise but want to start a .com where I'll be get...

SQL Server locking problem on popular table

I've run into an issue that I need clearer heads to think through. Occasionally this stored procedure (and many others similar to it): CREATE PROC [dbo].[add_address1] @recno int OUTPUT, @clientID int, @street varchar (23), @city varchar (21), @state varchar (2), @zip varchar (9) AS declare @s int; select @s = updated from is_c...

SQL Server 2008 Intellisense - Typing 'top' brings up tables, causes confusion

Hey everyone, SQL Server 2008 introduced Intellisense while writing queries. Problem is, whenever I type in "SELECT TOP" and press space, it replaces TOP with a table named 'Top3_Animations'... Is there a way to add "TOP" to the Intellisense list? Or to fix this some other way? Bara ...

Is there any performance difference between SQL Server Web and Express editions?

I have a VPS with Windows Server 2008 R2, 1 GB RAM with Dual Processor Quad Core 2 CORES. My sample application is running slower than my current website on shared hosting, when I asked the reason the says following reason. "SQL Server Express tends to be slower compared to SQL Server Web edition. This is due to the limitations imposed...

How upgrade varchar(8000)?

I wand to upgrade my varchar(8000) to more data(I mean , I want to increase 8000) what I will do for this? Hoping for your support. ...

Getting error while writing script to create a table

I am working on sql server 2005. I am writing a T sql script which will need to add a table to the database, but i want to add the check that if the table is already created. But my script is giving me this error message: Msg 102, Level 15, State 1, Line 7 Incorrect syntax near 'ON'. Msg 2714, Level 16, State 6, Line 1 There is already ...

intermittent problem occurring with a table that is only used for selection

I have a database running on SQL Server 2008. An exception throws when any statement refers to one specific table called 'stop': Msg 6533, Level 16, State 48, Line 1 AppDomain mssqlsystemresource.sys[runtime].12171 was unloaded by escalation policy to ensure the consistency of your application. Out of memory happened while accessing a c...

Asp.net - Microsoft SQL Server outgoing connections

Hello Stackoverflowers, I was wondering if there is a way to see if a server blocks outgoing connections. I am trying to connect to an external database from a client's server. This is the error I get: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or w...

how to change this sql query

SELECT * FROM dbo.tbh_table WHERE TopicID IN ( SELECT value FROM dbo.fn_split('19,',') ) I have to change above query to execute result like below SELECT * FROM dbo.tbh_table WHERE TopicID LIKE '%19,%' My topicID values are like this 15,19,12,1 But split will give values are 15 19 12 1. because of which i am not able to ex...

Why would a SELECT statement be 45% of the execution plan cost in SQL Server 2008?

I have a query where I select a few columns from each of 5 left outer joined tables. I did an execution plan in SQL Server 2008, and there are basically table scans on all of the joined tables, but the cost is all 0% for them - I'm assuming because there aren't many records in these tables. Then at the last 2 steps of the execution p...

Compatibility - SQL 2005 vs 2000

I recently changed my compatibility mode of my sql server 2005 form 2000 to 2005. Is there a utility that can scan my sp and functions and tell me if I have any compatibility issues? ...

Sql Update statement issues...

I am trying desperately to create a final table for a production envirnment, however Im having some issues.... I have 2 tables in my database. MyTable has exactly the same format as the other (AnotherTable). AnotherTable has the final value that I'd like to be in MyTable. I am trying to update MyTable's gq value to equal the value in...

bcp Logon error

I continually get a logon error no matter which logon I use or from what tool I approach this (shell/sqlsms) output ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------...

using linq2sql, what if my db model doesn't have any relationships mapped? ramifications?

My database doesn't have any FK mapped in the tables, only PK indexes. If I use linq2sql, what are the ramifications of this db design? ...

Is it possible to restore a SQL Server database from a virtual drive?

In SQL Server Management Studio, if I attempt to restore a database from a backup file with a command like: RESTORE DATABASE somedatabase FROM DISK = '<virtual disk>:\<path>\<backup file>'; I get a "file not found" error. I'm creating with the "subst" command. But if I replace with a physical disk and with the complete path, the ...

Gotchas with SQL Server Full-Text Search

I want to compile a list of gotchas when using SQL Server full-text search in all versions. For instance, Here's a SQL Server Full-Text gotcha: SQL Server 2008 R2 has a new feature called Data-Tier Applications - which is a way to package a database schema meant to be deployed elsewhere. Certain objects like Full-Text Ca...

INSERT data ignoring current transaction

I have a table in my database which essentially serves as a logging destination. I use it with following code pattern in my SQL code: BEGIN TRY ... END TRY BEGIN CATCH INSERT INTO [dbo.errors] (...) VALUES ( ERROR_PROCEDURE(), ERROR_NUMBER(), ERROR_MESSAGE(), ... ) END CATCH To make long story short some of this code mus...

Does this code prevent SQL injection?

Background I've been contracted to analyze an existing Data Provider and I know the following code is faulty; but in order to point out how bad it is, I need to prove that it's susceptible to SQL injection. Question What "Key" parameter could break the PrepareString function and allow me to execute a DROP statement? Code Snippet P...

How do I upload a file to a varbinary(max) column in SQL Server 2008, using TSQL?

This must be possible because I believe I've done it before. Here's my query: insert into exampleFiles Values(NEWID(), cast('c:\filename.zip' as varbinary(max)) Obviously that just inserts the text in between the quotes and not the file from that location. There must be a simple tsql bit of language that I'm forgetting. Thanks ...