sql-server-2008

Please help me with database connection types in Windows.

Sorry for a badly-phrased question. I have a requirement coming from a non-technical person that I need to make sense of. I am basically told: "Here use 'Driver={SQL Server};Server=SERVERNAME\INSTANCENAME;Database=DATABASENAME;Uid=UNAME;Pwd=PASSWORD;'; and here use Server=SERVERNAME\INSTANCENAME;Database=DATABASENAME;Uid=UNAME;Pwd=PASSWO...

Physical operators in SQL Server execution plans: what are rebinds, rewinds and number of executions?

I'm trying to understand physical operators in SQL Server execution plans. This page is quite helpful: http://technet.microsoft.com/en-us/library/ms191158.aspx SSMS 2008 shows some physical operator properties that are not displayed in SSMS 2005: Estimated Number of Executions and Number of Executions. But what do these actually mean, ...

T-SQL String Functions: difference between using Left/Right and Substring and strange behaviour

I am using SQL Server 2008 & 2005 (Express). I'm trying to extract part of an alpha numeric string from a varchar field. RIGHT(str_field, 3) yields null values but SUBSTRING(str_field, LEN(str_field)-2, LEN(str_field)) gives the right value. LEFT(str_field, 7) gives the expected values. What gives? I would have thought that RIGHT(st...

joins in SQL Server 2008

How many joins allowed in SQL Server 2008? ...

How to get SQL Function run a different query and return value from either query?

I need a function, but cannot seem to get it quite right, I have looked at examples here and elsewhere and cannot seem to get this just right, I need an optional item to be included in my query, I have this query (which works): SELECT TOP 100 PERCENT SKU, Description, LEN(CONVERT(VARCHAR (1000),Description)) AS LenDesc FROM tblItem WHER...

How to store and compare time-zone sensitive times

I have a data structure where an entity has times stored as an int (minutes into the day) for fast comparison. The entity also has a Foreign Key reference back to a TimeZone table which contains the .NET CLR ID Name and it's Standard Time/Daylight Time acronyms. Since this information is stored as time-zone insensitive - I was wonderin...

In SQL Server 2008, when would I use a full text index that covered several tables?

I wanted to do a full text search across several related tables in SQL Server 2008. From browsing this site I've realised the best option is via a view, but initially I thought I was meant to add several tables to the same full text index via Management Studio. I started to do this and realised the index would have no idea how they were ...

How can upload image URL in SQL server and retrieve in grid view using ASP.NET?

How to upload image URL in SQL server and retrieve in grid view using ASP.NET? Can you point me to any tutorials and/or sample code? ...

Get data types from arbitrary sql statement in SQL Server 2008

Given some arbitrary SQL I would like to get the data types of the returned columns. The statement might join many tables, views, TVFs, etc. I know I could create a view based on the query and get the datatypes from that, hoping there's a quicker way. Only think I've been able to think of is writing a .net utility to run the SQL and e...

SQL Server 2008 SQLCLR Issue

I have a SQLCLR that was originally running on SQL Server 2005 DB. I have since rebuilt the CLR to run on SQL Server 2008. The CLR requires a reference to WindowsBase.dll. I added WindowsBase.dll as an assembly to the SQL Server 2008 DB. When I try to use the rebuilt CLR I get the message Could not load file or assembly 'WindowsBase...

Changing multiple values in an XML column in SQL Server 2008

I've got a column in a SQL Server table that is type XML. I want to change multiple values in the XML in a stored proc. I've already found the XML.Modify(...) command and have it working for a single value. Can I change multiple values in the XML in one update command or do I need to do it as multuple update commands? ...

Problems installing SQL Server 2008 on Windows 7 Pro

I'm having no luck. I've tried installing SQL Server 2008 Express on my Windows 7 Pro box about 4 times now. Each time it installs the 'setup files required' then does nothing. All I can do is click the 'New ... or Add Features...' link to try starting again but get the same results each time. Any developers experienced this before? ...

SQL Server: sp_help with Default Values

Is there an alternative to sp_help that includes the default values for parameters? ...

Database Mirroring of SQL server

I have two databases that are mirrored to another server using database mirroring. The mirror server has to be down for some reason for few days. Now the production server is having principal databases in (PRINCIPAL/DISCONNECTED) State. Clients can access those databases. So what happens when they keep on adding data to these databases?...

Storing website hierarchy in Sql Server 2008

I want to store website page hierarchy in a table. What I would like to achieve is efficiently 1) resolve (last valid) item by path (e.g. "/blogs/programming/tags/asp.net,sql-server", "/blogs/programming/hello-world" ) 2) get ancestor items for breadcrump 3) edit an item without updating the whole tree of children, grand children etc. ...

Trouble with a query

Hi there, I'm having trouble with a query in SQL Server 2008 on some forex trading data. I have a trades table and an orders table. A trade needs to comprise of 2 or more orders. DDL schema and sample data below. What I want to do is write a query that shows the profit/loss in pips for each trade. A pip is 1/1000th of a currency. So th...

SQL Server ORDER BY/WHERE with nested select

I'm trying to get SQL Server to order by a column from a nested select. I know this isn't the best way of doing this but it needs to be done. I have two tables, Bookings and BookingItems. BookingItems contains StartDate and EndDate fields, and there can be multiple BookingItems on a Booking. I need to find the earliest startdate and lat...

Why does "non exists" SQL query work and "not in" doesn't

I spent some time trying to figure out why this query isn't pulling the results i expected: SELECT * FROM NGS WHERE ESPSSN NOT IN (SELECT SSN FROM CENSUS) finally i tried writing the query another way and this ended up getting the expected results: SELECT * FROM NGS n WHERE NOT EXISTS (SELECT * FROM CENSUS WHERE SSN = n.ESPSSN) The...

How can I use SSIS to create an output row in one table, get the identity from that table for a new row in another table?

Is there a way we can process rows from one input table to two output tables where the first output table has an identity field? We are using SQL Server 2008 SSIS. We need to post the record in the first output table to get the identity field int value to use when posting the second output table's row. The example is Borrower and CoBor...

VS 2010 build database project receive SQL04151

I just started working with the Visual Studio 2010 Premium database project. I must say it does indeed rock. One thing I can't figure out is how to avoid teh SQL04151 warning "Procedure: [dbo].[MyProc] has an unresolved reference to object [MyDatabase].[dbo].[MyItem]". Did I miss a simple step somewhere? All I can find online involves te...