sql-server

SQL select joined string for set of ids

I have to deal with a mssql database and the information given in a table like this: Users: ID Name Countries -------------------- 1 User1 1,2,3 2 User2 2,5 Countries: ID Country ---------- 1 Australia 2 Germany 3 USA 4 Norway 5 Canada Now, what i am looking for is a select statement that will give me a result like thi...

Connecting To SQL Server DB Using VS2008

I am using VS2008, and usually I'll develop my sites from the App_Data folder and then just upload the whole site to the server. Now I have a site and the SQL DB is running on the server already (Not in the App_Data folder , I use SQL Studio Mgement to connect to it and edit), so instead making the changes to the local DB and then again...

SmoApplication.EnumAvailableSqlServers() does not list default instance if sqlexpress is in same machine where SQLSERVER2008 installed

Hi I am using SMO to find available sqlservers of a network.But in one machine where i running application it doesnot give Default instance name but for all other machines it gives the named and default instance wil be showing. Observe my Scenario. Ex: Machine Name :rkwrk3-vm-sr (local machine from where i am running app in which ...

Iterate Xml Column elements and comapre against Xml Variable

Hi, I'm not sure how to word this correctly but I'm very (very) new to XML in Sql Server. I have an XML Column defined in a table and I want to retrieve the id of the record if the data in the Xml Column matches elements in a predefined list. The data looks a bit like this: <Parameters> <Parameter> <Name>Param1</Name> ...

UPSERT in SSIS

I am writing an SSIS package to run on SQL Server 2008. How do you do an UPSERT in SSIS? IF KEY NOT EXISTS INSERT ELSE IF DATA CHANGED UPDATE ENDIF ENDIF ...

T-SQL match special characters. Pre should match Pré.

I have a list of company names and the user has to enter his company name to get into the system. Let's say we have the company "Pré ABC", now I want the user to be able to type "Pre" or "Pré". First I thought this was build-in functionality of the LIKE statement, but unfortunately it isn't. Any thoughts? ...

SQL query: time difference

Hi all, This is going to seem like a lame question for all experts in SQL server views but... So I have a small set of data that my client needs for reporting purposes. I have to admit that although I did ask them their reporting requirements, it isn't till now that I see that my db could be better optimised. One of the pieces of data...

Transferring databases between SQL Server instances

I have mdf & ldf files from another machine and want to add these databases to my machine, how can I do that?......Thanks When I try to attach the database I get the following error: Error 602: could not find row in sysindexes for database id 7 object id 1. Run DBCC CHECKTABLE ...

.mdf created in Visual Studio

Hi, my colleague created .mdf and .ldf files from Visual Studio. Now, I'm trying to access the file in SQL Server. There seems to be a problem with this. Can anybody tell me what edition of SQL Server must I have on my Windows Vista 32-bit, so I can access this database. Thanks in advance. :) ...

Need help with a SQL query that combines adjacent rows into a single row

Hi all, I need a solution to a problem that has the table structure as listed below. Input 1 1/1/2009 Product1 2 2/2/2009 Product2 3 3/3/2009 Product3 4 4/4/2009 Product4 5 5/5/2009 Product5 Output 1 1/1/2009 2/2009 Product1 2 3/3/2009 4/4/2009 Product3 3 5/5/2009            Product5 I tried using CTE. But was not ...

BCP Utility

Hi, I need to have ability in my application to be able to export some data using the SQL Server BCP utitility. The machines where this utility would run would not have SQL Native Client installed on it, so BCP.exe won't be present by default. Can I put a version of BCP in the installation package. What are licensing implications? I ...

Accessing C# Variable from Javascript?

In my MS SQL table, I read in an "time_zone" for a city from a record. I then want to use this time zone in a Javascript function to create a digital clock for that city. Currently I am trying to set the time_zone variable from Here's a code snippet from Default.aspx: function showtime() { zone(hiddenZone...

What am I doing wrong with this query?

Hello, I can't seem to find why this function doesn't insert records into the database. :( I get no error messages or whatsoever, just nothing in the database. EDIT: this is how my query looks now .. still nothing .. connection.Open(); XmlNodeList nodeItem = rssDoc.SelectNodes("/edno23/posts/post"); foreach (XmlNode xn in nodeItem)...

How to reformat and sort dates stored in nvarchar

I am trying to display Month and YY part of the date column such that it should appear as Original Format Apr 12 2009; Feb 20 2009; Dec 24 2008; May 18 2009; Jan 8 2009; Dec 6 2008; Apr 19 2009; Jan 4 2009; May 13 2009; Jan 5 2009 From these dates the day part should be ripped off such that it appears as "Apr 09" ...

SSRS: 2005, CSS not applied on first column

Some of our reports aren't displaying properly in Firefox - the first column lacks any css. After investigating, I'm finding: <tr> <td style="HEIGHT:6.93mm" style="...">1st Column</td> <td style="...">2nd Column</td> <td style="...">3rd Column</td> </tr> When I remove the style="HEIGHT:6.93mm", it renders properly in Firefox. ...

tsql : how do you query with dashes in column names?

I have the query select * from products p, products_temp t where p.ManufacturerPartNumber = t.[INV-PRICE-VENDOR-PART] where the column names have dashes in them which SQL Server 2005 seems to automatically add brackets to. What is the correct way of accessing this in a query? I've tried with brackets and without the brackets and ju...

Import WebTrends Data to SQL Server Using SSIS

Hi All, I need to import all the webtrends data to my local sql server database. on top of that i need to build reports. I am very new to Webtrends, so can some one suggest me how to import the WebTrends data to my local DB Server. Thanks ...

SQL Server 2000 + ASP.NET: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I just migrated a development workstation FROM: Windows XP Pro SP3 with IIS 6 TO: Vista Enterprise 64bit with IIS 7 Since the move, one of my pages that accesses an SQL Server 2000 database is receiving the following error from my ASP.NET 2.0 web page: "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." I have: enabled Windows...

Is it bad practices to allow null fields to a DB Table in order to simplify Model Binding from Ajax?

Please read here and here to get a quick overview of my problem and to see exactly what I mean when I say Model Binding from Ajax. Would it be a bad idea to make the foreign key fields nullable in order to allow for Model Binding from javascript? For example, we want to bind to a Person object during an ajax call to... (The Person cla...

Is it of any drawback if a table has many (20+) foreign key constraints?

Let's says I have a table which has many fields linked to values from other "value tables". Naturally, I declare foreign key constraints on each and evary of them to enforce integrity. What if I finally get the number of such fields in the range of 20-30? Will it somehow "slow" table operations or not really? ADDED: Value tables are ex...