sql-server

Coalescing rows based on field value in row.

I have a table with tax rates where NULL entity type rows represent the default tax rates. Year End | EntityType | RateType | TaxRate ------------------------------------------ 2009 | NULL | Interest | 13 2009 | NULL | Other | 8 2009 | NULL | Interest | 13 2010 | NULL | Other | 9 2009...

How do I partition efficiently in SQL Server based on foreign keys?

I am working on SQL Server and want to create a partition on a table. I want to base it off of a foreign key which is in another table. table1 ( fk uniqueidentifier, data ) fk points to table2 table 2 ( partition element here ) I want to partition table1 base on table2's data, ie if table2 contains categories ...

SQL Server Create multiple foreign keys

The table contains a PRIMARY KEY column and another column which is FOREIGN KEY. This works fine. When I attempt to add another column as a FOREIGN KEY I get the following message: Link to pic ...

Connect to SQL Server to run T-SQL use other's domain account.

Hi all In our database we have an SQL server account that has the correct roles to access some of the databases. All of our PC and Servers are in domain using Windows Account. Now there is ASP.NET web application, we want the users in the domain to browser some data in the sql server. But we do not want to grant direct permission to eve...

How to SPLIT the data in SQL server 2008 based on the length not on delimiter

Hi all, I have a query to split the data but it is based on a delimiter. My query is: DECLARE @xml xml,@str varchar(100),@delimiter varchar(10) SET @str= 'VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR,VINAYKUMAR' SET @delimiter =',' SET @xml = cast(('<X>'+replace(@str,@delimiter ,'</X><X>')+'</X>') as xml) select @x...

Reporting services -- Export excel with data

Hello, I have a report showed as bar chart in sql server reporting services. when I export it to excel from the reporting services web interface, the exported file doesn't contain any data, it only has a bar chart image. Is there any way to make it export to excel with data? ...

Concerned with replicate fn in sql

hi guys, I am using following query create table #Attendence (id int identity(1,1),det varchar(2000)) insert into #Attendence (det ) select --convert(char(10),@Date,3) +REPLICATE(' ', 20 - LEN(convert(char(10),@Date,3)))+ staff.StaffNAme +REPLICATE(' ', 20 - LEN(staff.StaffNAme ))+ case Att.FN when 1 then 'Prese...

How to a remove all database indexes from a SQL server database

I am about to write a script to add new indexes to a database, I wish that script to work regardless of the current indexes the database has. Therefore the first step in the script should be to remove all the current indexes. (I could just as easily run .net code, but I think TSQL will be less painful for this type of thing) (This is ...

Tricky logic problem - how to create a set-based solution for this query?

Using SQL Server 2008 and any available features of TSQL, I am trying to work out how to if a set-based solution that does not involve a temp table exists for the following problem: Given a set of nodes that have a parent-child relationship, and a set of key-value pairs that apply to each, and given that the value (for a given key-value...

whether the 'identity' used in sql server has been used twice inside same table.

whether the 'identity' used in sql server has been used twice inside same table. ex: i need to insert some set of records with the identity column starting from 0,1,2.... and when i insert some another set of records again the identity must start with 0,1,2.. is there is any possiblity to achieve that using the identity seed. ...

Mapping complex result set with Dom4j

I'm trying to create an XML document from a complex result set, i.e. a result set with multiple joins, so a competition has a bunch of questions, and a question has a bunch of answers. So the document would end up looking something like: <competitions> <competition id="12"> <question id="3"> <answer id="34"> The ans...

how to pass this information to SQL Server 2008?

Please visit http://www.stumbleupon.com/ It asks you what interests you. I would have a similar thing on my website except I would need to have 4 of such non-identical blocks. When a user has not selected anything in a section, it means s/he has selected all of them. 1 of these blocks would have around 10 options while the other 3 woul...

Help with generating a report from data in a parent-children model

Hi, I need help with a problem regarding data saved in a parent-children model table and a report I need to build upon it. I've already tried searching for topics about parent-children issues, but I couldn't find anything useful in my scenario. What I have A Microsoft SQL Server 2000 database server. A categories table, which has four...

IF Not Exist then Inseting a value in the table

Using SQL Server 2005, vb.net Table1 Name FromDate ToDate Raja 12/02/2010 14/02/2010 Ravi 14/02/2010 15/02/2010 Ramu 18/02/2010 21/02/2010 ..., Insert into Table1 values('" & textbox1.text & "', '" & textbox2.text & "'. '" & textbox3.text & "'", con) When i try to insert a value into table1 it will compare the table values if it i...

date format and regional settings

Hi all, I'm using MS SQL 2000, VS2008, MVC and C#. I'm trying to insert and update some data using stored procedures. Some columns are of type datetime. Regional settings on both server and client are set to Dutch (Belgium) This means the default date format is dd/mm/yyyy. When i try to insert or update with a date of eg. 28/03/2009,...

broken SQL 2008 SP1 Web Edition (can not login with SSMS)

Scenario: My installation of SQL Server 2008 Web Edition SP1 was working properly. Since I've recently joined Microsoft's Website Spark*, I removed SQL2008 and installed SQL 2008 again using my Website Spark edition and license from the MSDN download site. Next, I updated SQL 2008 to SP1 (this is required because I'm running Windows 2...

Is their a definitive list for the differences between the current version of SQL Azure and SQL Server 2008?

I am a relative newbie when it comes to SQL Azure!! I was wondering if there was a definitive list somewhere regarding what is and is not supported by SQL Azure in regards to SQL Server 2008? I have had a look through google but I've noticed some of the blog posts are missing things which I have found through my own testing: For example...

Sql Outer Join: Extracting values from multible tables.

I am extracting data from multiple tables. mt query is as follows: SELECT p.Record_Num as RecordNum ,p.GCD_ID as GCDID ,p.Project_Desc as ProjectDesc ,p.Proponent_Name as ProponentName ,st.Station_Name as StationName ,p.OpCentre as OpCentre ,s.Sector_Name as SectorName ,p.PLZone as PLZone ,f.Feeder_Desc as FeederDesc ,d.DxTx_Desc as DxT...

What is the most cost-effective way to break up a centralised database?

Following on from this question... What to do when you’ve really screwed up the design of a distributed system? ... the client has reluctantly asked me to quote for option 3 (the expensive one), so they can compare prices to a company in India. So, they want me to quote (hmm). In order for me to get this as accurate as possible, I w...

Could not open a connection to sql server

i am running this in the command line: sqlcmd -s .\SQLexpress and the output i get is: HResult 0x2, Level 16, State 1 Named Pipes Provider: Could not open a connection to SQL Server [2]. Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or in stance-specific error has occurred while establishing a connection ...