sql-server

Limiting File Attachments to a SQL Server 2005 DB to a value > 8000 bytes

I have a .Net app that will allow the users to attach files to a SQL Server 2005 database. I want to limit the filesize to 10MB, so from what I can tell, I have to declare the datatype varbinary(max), since the max size I can actually specify is 8000 bytes. But the ~2GB filesize varbinary(max) allows seems like overkill. Is there a wa...

Easiest way to copy an entire SQL server Database from a server to local SQL Express

I need to copy an entire database from a SQL Server 2005 on my server over to my local SQL Express in order to run my application for a presentation. What is the fastest/easiest way to get this done? EDIT: I have very limited access to my server so I don't think I can access the backup file that I could create so that is out. ...

How to Select data from Table from a DSN in T-SQL?

How can I get data from a database that I can only access through an ODBC Data Source (DSN) in T-SQL MS SQL Server, any version? ...

How to specify the reply-to address using sp_send_dbmail in SQL Server

I need to send an email to someone and want them to be able to simply reply to the email without having to specify the email address. Using sp_send_dbmail sets the reply-to address as the name of the profile that it was sent from. Can this be changed to specify the reply-to so it looks like it came from me. Thanks. ...

SqlDateTime overflow Exception

Hi, I am trying to insert a time only value, but get the following error ex {"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."} System.Exception From the front end, the time is selected using the "TimeEdit" control, with the up and down arrows. The table in SQL Server has the fields set ...

Building a temp table /map

I'm working on a stored procedure in SQL Server 2000 with a temp table defined like this: CREATE TABLE #MapTable (Category varchar(40), Code char(5)) After creating the table I want to insert some standard records (which will then be supplemented dynamically in the procedure). Each category (about 10) will have several codes (typicall...

How do I delete excel rows in SSIS?

Is it possible to delete rows in an excel worksheet from SSIS? ...

Best way to track changes and make changes from Mysql -> MSSQL

So I need to track changes that happen on a Mysql table. I was thinking of using triggers to log all the changes made to it and then save these changes in another table. Then I will have a cron script get all these changes and propagate the changes into the Mssql database. I really dont expect a lot of information to be proporgated, but...

Ranking method used by SQL Server for Fulltext indexing

I'm having some problems with the ranking used by fulltext search in SQL Server. Suppose a user searches for two words, "foo bar". We assume the user intends to do an OR search, so we pass "foo OR bar" to our CONTAINSTABLE call. What we're finding is that an row that contains "foo" 10 times but does not contain "bar" will have a much ...

Autocomplete on SQL Management Studio?

Does anyone know if there's an add-in that does autocomplete for queries on SQL Management Studio? ...

What to do about @p LINQtoSQL parameters? What is @p anyhow?

Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application I got this piece of code from Microsoft to cache LINQtoSQL, basically what it does is it gets the SqlCommand text from the LINQ query and executes that via the System.Data.SqlClient.SqlCommand which SqlDependecy needs... However there is one slight prob...

How to create column names/descriptors programmatically

In SQL Server given a Table/View how can you generate a definition of the Table/View in the form: C1 int, C2 varchar(20), C3 double The information required to do it is contained in the meta-tables of SQL Server but is there a standard script / IDE faciltity to output the data contained there in the form described above ?. Fo...

How does SQL know what @p# in LINQtoSQL queries?

I want to know how does the SQL Server know what @p# is in say this LINQtoSQL quey SELECT [t0].[MemberID], [t0].[Aspnetusername], [t0].[Aspnetpassword], [t0].[EmailAddr], [t0].[DateCreated], [t0].[Location], [t0].[DaimokuGoal], [t0].[PreviewImageID], [t0].[LastDaimoku] AS [LastDaimoku], [t0].[LastNotefied] AS [LastNotefied], [t0].[La...

SQL to Linq Expression?

Does anyone know of a tool to take a T-SQL query and convert it into a LINQtoSQL query? ...

What settings for a read database, and what settings for a write database?

Hi, I am implementing replication for a project I am developing, and would like to replicate changes in the Write database to the Read database. While this isn't a problem, I want to tune one database for reading from, and the other to writing to, so they would have different settings. Is there any resource/guide which will tell me wh...

Persisting a computed datetime column in SQL Server 2005

I have an XML column in a table; I want to "promote" a certain value in that XML as a computed column and index it for faster searching. I have a function that takes in the XML information and outputs the element of interest, like this: CREATE FUNCTION [dbo].[fComputeValue] (@data XML) RETURNS datetime WITH SCHEMABINDING AS BEGIN RETU...

Data timeline performance in Sql Server

I have a table with three columns: user varchar, status varchar , rep int status and rep get updated often and one of the requirements is: Given a datetime value view status and rep values, for each user, at the given date. I can add an updated_at datetime column to the table and insert new rows whith the same user instead of update ...

T-SQL fuzzy lookup without SSIS?

SSIS 2005/2008 does fuzzy lookups and groupings. Is there a feature that does the same in T-SQL? ...

Output Parameter not Returned from Stored Proc.

I am calling a SQL proc that has 3 OUTPUT params. After the call to the proc one of the params does not return a value when the other two do. Profiler shows that all 3 values are being returned. The params are declared as follows in the proc... @UsrVariableID INT OUTPUT, @OrganisationName NVARCHAR(256) OUTPUT, @Visible bit OUTPUT and...

How can I copy a SQL Server 2005 database from production to development?

We have a production SQL Server 2005 database server with the production version of our application's database on it. I would like to be able to copy down the data contents of the production database to a development server for testing. Several sites (and Microsoft's forums) suggest using the Backup/Restore options to copy databases fr...