sql-server

File / Image Replication

Hi, I have a simple question and wish to hear others' experiences regarding which is the best way to replicate images across multiple hosts. I have determined that storing images in the database and then using database replication over multiple hosts would result in maximum availability. The worry I have with the filesystem is the dif...

In SQL Server 2005, is there an easy way to "copy" permissions on an object from one user/role to another?

I asked another question about roles and permissions, which mostly served to reveal my ignorance. One of the other outcomes was the advice that one should generally stay away from mucking with permissions for the "public" role. OK, fine, but if I've already done so and want to re-assign the same permissions to a custom/"flexible" role,...

Best practice for graceful replace of read-only SQL Server database

I have a read-only database that has cached information which is used to display pages on the site. There are processes that run to generate the database, and those run on a different server. When I need to update the live database, I restore this database to the live server, to a new name and file. Then I drop the live database and rena...

Funky Line feeds in MS SQL

When I inserted text from one SQL Server VARCHAR(MAX) field in one database to another, I get question mark symbols - "?" - in the target database (in addition to line feeds) whenever there are line feeds in the source database. Text in the target database looks like this: Line one.? ? Line two.? ? Any ideas about what could cause thi...

Inserting taking longer on Sql Server 2005 table

I have a table with about 45 columns and as more data goes in, the longer it takes for the inserts to happen. I have increased the size of the data and log files, reduced the fill factor on all the indexes on that table, and still slower and slower insert times. Any ideas would be GREATLY appreciated. ...

Permissions required for 'CREATE USER' in SQL Server 2005?

Hi - I am trying to create a SQL server login and database user from within my application, along with a custom application user row. I want these users to be able to create other users - i.e. the application will control who can/can't create users but I need all users to have permissions for creating SQL server logins and database users...

How to define a user-defined data type with addressable members?

I have an unusual situation to model in a MS SQL Server database: the primary key of a table is a multi-segment 'natural' key composed of 5 foreign keys (of fixed sizes). I'd like to be able to define a user-defined data type to implement the data structure based on a CHAR(8) primitive in such a way that the elements are addressable as ...

SQL Server BCP insert additional columns

Hi My reuirement: Input File: 1,abc,xyx 2,def,mno 3,ghi,suv DB Table Structure: Col1 char col2 char col3 char col4 char col5 char Data in Table after BCP: col1 col2 col3 col4 col5 1 abc xyz ab xy 2 def mno de mn 3 ghi suv gh su Basically the col4 and col5 are calculated values from col2 and col3 v...

Does large SQL Server Memory Usage cause errors?

Just started getting a bunch of errors on our C# .Net app that seemed to be happening for no reason. Things like System.IndexOutOfRangeException on a SqlDataReader object for an index that should be returned and has been returning for a while now. Anyways, I looked at the Task Manager and saw that sqlservr.exe was running at around 1,50...

Full text search on a table

How to enable and perform a "full text" search on a table in SQL Server 2005? I did not quite understand the solution in: http://stackoverflow.com/questions/206142/how-do-i-use-full-text-search-accross-multiple-tables-mssql-2005 ...

Which settings should be thoroughly evaluated in SQL Server?

I am not a DBA by any means, but being a web developer means that I will have to install, setup, and administer databases. In the past, I have just followed the default installation for SQL Server. Over time, I have grown smarter and learned that default installations almost always leave doors open and leak. So...What are the critical s...

Scaling out SQL Server for the web (Single Writer Multiple Readers)

Has anyone had any experience scaling out SQL Server in a multi reader single writer fashion. If not can anyone suggest a suitable alternative for a read intensive web application, that they have experience with ...

SQL Server View Problem

We have a View (call it X) that is the base view called by 2 other views(call them Y and Z). Today we made a change to view X, after that view Y and Z started bringing back data that was incorrect. When we were in Management Studio and ran Select * from Y(which is exactly how the view is called in in code) it would get back data that w...

Geometry column: STGeomFromText and SRID (what is an SRID?)

I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008) DECLARE @region geography; set @region = geography::STGeomFromText('POLYGON(( -80.0 50.0, -90.0 50.0, -90.0 25.0, -80.0 25.0, -80.0 50.0))', 4326); SELECT @region; My question is...

Login dialog appear in IE7 when browsing SQL Reporting Services

Setup is SQL2005 SP2 with Reporting Services installed local on Win2003 64bit. When users browse report manager on http://server/reports they get login dialog for every request, but only if they use IE7. In FireFox all works. The site is in "local intranet" zone on IE. It seems like it is a NTLM, I've tested reinstall, change permissio...

Group repeated rows in TSQL

I have the following table and data in SQL Server 2005: create table LogEntries ( ID int identity, LogEntry varchar(100) ) insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('beans') insert into LogEntries values ('cabbage') insert into LogEntries values ('cabbage') insert...

Is there a way to optimize the query given below

I have the following Query and i need the query to fetch data from SomeTable based on the filter criteria present in the Someothertable. If there is nothing present in SomeOtherTable Query should return me all the data present in SomeTable SQL SERVER 2005 SomeOtherTable does not have any indexes or any constraint all fields are char(5...

Problem inserting string or NULL into SQL Server database

I'm having trouble coming up with the proper syntax for allowing either a string or a NULL to be passed to the database. Here's my code: string insertString = String.Format( @"INSERT INTO upload_history (field1, field2, field3) VALUES ('{0}', '{1}', '{2}')", varField1, varField2, varField3); I used single quotes around th...

How do I select only the latest entry in a table?

I have a 3 table SQLServer Database. Project ProjectID ProjectName Thing ThingID ThingName ProjectThingLink ProjectID ThingID CreatedDate When a Thing is ascribed to a Project an entry is put in the ProjectThingLink table. Things can move between Projects. The CreatedDate is used to know which Project a Thing was last moved too. I ...

How Do I Follow A T-SQL Transaction?

Are there any programs that will allow you to follow a sql transaction through to it's end? For instance, say I've inherited a rather complex sql database with a data dictionary. The data dictionary is pretty good, but not as good as say, SQL Doc. I've taken a look at Red Gate's Dependency Tracker and, while that does a very good job ...