sql-server-2008

Implications of Fulltext Search over many columns

Hello, I have a really wide table which includes separate columns for billing address, shipping address, primary address, names, aliases etc. (I can't normalize this table further, and that's not the question here anyways). I'm implementing SQL Server fulltext search, and I'm wondering whether I should limit the search ability to just t...

Bulk update + SQL + self join

Hello All I would like to update a column in Table with reference to other column(s) in same table. Ex: As in figure below - I would like to update effective endate with min date whichever is greater than effective Start Date of currrent record. How can this be acheived in T-SQL. Can this be done with single update statement ? Th...

Performance of inter-database query (between linked servers)

I have an import between 2 linked servers. I basically got to get the data from a multiple join into a table on my side. The current query is something like this: select a.* from db1.dbo.tbl1 a inner join db1.dbo.tbl2 on ... inner join db1.dbo.tbl3 on ... inner join db1.dbo.tbl4 on ... inner join db2.dbo.mysid...

Stored Procedure Permissions Problem

I have migrated a set of SQL 2000 databases to SQL 2008. Most is working well, however I have some stored procedures that scheduled and run by SQL Server Agent jobs that are giving me troubles. Many of the scheduled stored procedures work, but the stored procs that access a database other than the default databases are failing with the ...

Sql Server Replication: Snapshot vs Merge

Background information Let's say I have two database servers, both SQL Server 2008. One is in my LAN (ServerLocal), the other one is on a remote hosting environment (ServerRemote). I have created a database on ServerLocal and have an exact copy of that database on ServerRemote. The database on ServerRemote is part of a web application a...

transaction log shipping sql server 2005 to 2008

I have a reporting setup with SSRS on our sql server 2005 database. Because sql server 2008 is not supported by the main program which populates our database we are stuck with 2005 on our prod database. Unfortunately when I run our weekly check reports the web interface constantly times out because the server cant do the conversion to PD...

Composite keys as Foreign Key?

I have the following table... TABLE: Accounts ID (int, PK, Identity) AccountType (int, PK) Username (varchar) Password (varchar) I have created a composite key out of ID and AccountType columns so that people can have the same username/password but different AccountTypes. Does this mean that for each foreign table that I try ...

How to secure the communication between a SQL Server database and a c# administrative tool?

How can I secure the communication between a C# programm running locally on my computer and a SQL Server in a hosted environment? I have an asp.net application that is secured by SSL encryption. So using the asp.net from an open wlan connection is no problem. How can I achieve the same kind of encryption for my administrative tool? Wou...

SQL2k8 T-SQL: Output into XML file

I have two tables Table Name: Graph UID1 UID2 ----------- 12 23 12 32 41 51 32 41 Table Name: Profiles NodeID UID Name ----------------- 1 12 Robs 2 23 Jones 3 32 Lim 4 41 Teo 5 51 Zacks I want to get an xml file like this: <graph directed="0"> <node id="1"> <att nam...

upsert with addition

How would you write the following in Microsoft SQL Server 2008? IF EXISTS(SELECT * FROM Table WHERE Something=1000) UPDATE Table SET Qty = Qty + 1 WHERE Something=1000 ELSE INSERT INTO Table(Something,Qty) VALUES(1000,1) ...

SQL Server 2008 BIDS without the Database Engine

Does anyone know how we can install BIDS for SQL Server 2008 without having to install the Database Engine? With the SQL Server 2008 Express install it appears to be mandatory to install the Database Engine when all we would like the end users to have access to is BIDS to develop their RDL's to deploy to an existing SSRS instance? It l...

Determine if an Index has been used as a hint

In SQL Server, there is the option to use query hints. eg SELECT c.ContactID FROM Person.Contact c WITH (INDEX(AK_Contact_rowguid)) I am in the process of getting rid of unused indexes and was wondering how I could go about determining if an index was used as a query hint. Does anyone have suggestions on how I could do this? Cheers...

sql - get the latest date of two columns

table1 - date1 datetime not null - date2 nvarchar null I want to get the latest date of this two. select date1, date2, (CASE WHEN date1 > CAST(date2 as DateTime) THEN date1 ELSE date2 END) as DateTime) as LatestDate from table1 please note that date2 can be null. in this case, date1 win. ...

Looking for a tool that can return SPs doing a DML on a table in SQL Server 2008

I am working on a big application on SQL Server 2008 with 60 000 stored procedures and over 10 000 tables. Is there a tool through which I can do impact analysis to find out all SPs doing a DML on a table? ...

Selecting a good SQL Server 2008 spatial index with large polygons

I'm having some fun trying to pick a decent SQL Server 2008 spatial index setup for a data set I am dealing with. The dataset is polygons, representing contours over the whole globe. There are 106,000 rows in the table, the polygons are stored in a geometry field. The issue I have is that many of the polygons cover a large portion of t...

SQL Server: Order by XML column's node

Hi, I was wondering can I ORDER BY my query by node of an XML typed column? For example I have a table ID (int) | Data (XML) Where Data column stores XML in form similar to this <?xml?> <Data> <SimpleOrderedValue>1</SimpleOrderedValue> <ComplicatedInternals> ... </ComplicatedInternals> </Data> I want query this tabl...

How to remove the secondary database created by sp_add_log_shipping_secondary_database

How to remove the secondary database created by sp_add_log_shipping_secondary_database ...

SQL CLR and nullable datetime parameter

I'm trying to write a SQLCLR function that takes a DateTime2 as input and returns another DateTime2. Based on this post I altered the parameter to be the C# type DateTime giving me the level of precision I require. However because the input can be null I would like it to be DateTime?; the return type as well. using System; using Micros...

SQL Server 2008 2mb Limit for XML??

I am trying to output a long XML result from SMSS. When I right click on the results and 'save results as...', I can only get a 2mb file? I have changed the settings in SMSS via Tools -> Options -> Query Results -> SQL Server -> Results to Grid, for XML data to be unlimited. However, it still seems to be truncating my XML results? S...

How do I do batch upserts in SQL Server?

I'm using the MERGE statement to upsert rows in an sql server 2008 database. However, my sproc is a single-row operation, whereas in fact I'd prefer to batch these. Is this even possible and, if so, how do I do it? ...