sql-server-2008

Wrong column types with SQLXMLBulkLoad

Hello, I am trying to bulk isnert XML Data into SQL Server 2008 Express with SQLXMLBulkLoad Object Model from C# (Visual Studio 2010). My problem is that I am stuck with the relationships. Consider the following annotated XSD file: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ...

How to automate script generation using SMO in SQL Server?

I would like to automate script generation (in SSMS --> Tasks --> Generate Scripts) in SSMS 2008. I have read that SQL Server 2008 does not support Database Publishing Wizard (including SQLPUBWIZ SCRIPT) but this automation can be done using SMO in SQL Server 2008. I don't have a clue about SMO and how to do this using SMO, so could you ...

Error when inserting data in non-unique index

I have a batch job that synchronizes data between two identical databases using the MERGE statement. Sometimes, I get the following error: cannot insert duplicate key row in object 'dbo.MatchPlayerStatistics' with unique index 'IX_MatchPlayerStatistics_Player'. That does not make sense because IX_MatchPlayerStatistics_Player is not a uni...

SQL Server 2008 tables name problem

hi, Could you tell me how to remove the database name from the table's name. Each time I create a table the database name is automatically prefixed to the name this is my table definition Create table Links ( Id Int IDEntity(1,1) , DisplayName Varchar(250) NOT NULL, Href Varchar(250) NOT NULL, Tooltip Varchar(550) NOT NULL, IsVisible...

How do I improve full-text searching

Hello, I have a SQL Server 2008 database. This database has 2 tables: Manufacturer ------------ ID, Name nvarchar(256) Product ------- ID ManufacturerID Name nvarchar(256) My application has a search box. I do not know if the user is going to provide a manufacturer name or a product name. In addition, I'm trying to be a little bit g...

profile name is not valid

Hi, I have a windows account with users group and trying to exec the sp_send_dbmail but getting an error: profile name is not valid. However, when I logged in as administrator and execute the sp_send_dbmail, it managed to send the email so obviously the profile name does exist on the server.. can anyone pleas help? ...

Enabling broker after Restoring Sql Server DataBase

Hello, I have DataBase with enabled Service Broker. Then I want to restore my database in program from backup of other database, but after restoring(I restore on existing database name), my method, whitch enables Service Broker, puts this error: Msg 9772, Level 16, State 1, Line 1 The Service Broker in database "ServeDB2" cannot be ...

SQL Server SQL Select: How do I select rows where sum of a column is within a specified multiple?

I have a process that needs to select rows from a Table (queued items) each row has a quantity column and I need to select rows where the quantities add to a specific multiple. The mulitple is the order of between around 4, 8, 10 (but could in theory be any multiple. (odd or even) Any suggestions on how to select rows where the sum of a...

date ranges in where clause of index view

I have an index view which I run a query against with WHERE GETDATE() BETWEEN start_date AND end_date in the WHERE clause. I suspect that the answer to my question is probably going to be no, but, is it possible to push this into the index view or do something clever to achieve the same effect? My concern is that what the index vi...

Newly Created Function Is Not Available?

I am working on a scalar value function in MSSQL 2008. I created it and It is shown in object Explorer But when I use this function in MS Query Analyzer It gave me error **Msg 208, Level 16, State 3, Line 1 Invalid object name 'calculatecptcodeprice'.** For Me this type of error after creating Function is new. What went wrong. Please ...

Dynamic dependency view SQL and SSIS packages

Hi All, In my enterprise project we have nearly 800 tables with 7 staging areas. We have developed nearly 100 packages to implement the DW. Business users constantly chaging the requirements after completing all the packages like table/column names, PK/FK columns with many other changes due to business requirements. Being changes in t...

T-SQL CTE Question (SQL Server 2008)

Hi, Why does the following query work, when there is no column named Agentid in the "NewAccounts"-CTE? WITH NewAccounts AS ( SELECT 3 as Newaccountid ), MovedAUM AS ( SELECT 1 AS Agentid, 2 as Col2 ) SELECT * FROM MovedAUM WHERE agentid IN (SELECT Agentid FROM NewAccounts) The following, modified query returns the error mess...

(free) tool to create word database design/shcema document from a sql server database

Looking to document a database schema after the event. I know red gate software have a commerical tool for this. I'm looking for a free tool to generate a word document from a SQL Server database. ...

Recursive Table How Reference To Load Data?

Hi All, I am planning on using a recursive table in my data model so that I can support an undetermined number of children that can live under a parent. My example is a Table of Contents where I don't know how deep my subsections will be under a chapter. The issue I am stumbling over is what techniques do folks use to populate there ...

Order a query with two keys SQL Server 2008

Hi, I am trying to order a query by two keys. The query is built with several subqueries. The table contains, beside columns with other data, two columns, Key and Key_Father. So I need to order the results since SQL to print the results in a report. This is an example: Key     Key_Father 4          NULL 1          4 2          4 7      ...

what is the to-char equivalent tsql/sql server 2008

I am used to oracle and now been thrown T-SQL, I am doing a course shortly but can you help out until then. I have a list that I need to group in minutes. Sample of rowdate data SELECT ROWDATE,count(rowdate) FROM [mydb].[dbo].[mytable] GROUP BY ROWDATE order by 1 2010-08-16 15:01:18.110 1 2010-08-16 15:01:18.203 1 2010-08-16 15:01:18...

Avoiding the use of SET TRUSTWORTHY ON

I'm working with a system which had to create objects in one database based on objects being created in another database. The objects are not duplicates, so I can't simply replicate the objects. I have code below which gives a simplified demonstration of what I'm trying to do. If you uncomment the ALTER DATABASE statements then it will ...

How do I find a disabled index on SQL server 2008

A while back when I was performing some bulk inserts of data into my SQL Server database, I disabled a number of indexes to improve the insert performance. I now need to go back and rebuild/re-enable them. Unfortunately, I'm not sure exactly which indexes I disabled. Is there a way I can query to identify which indexes are disabled an...

SQL Server Mangament Studio 2008 unable to connect to SSIS packages on SQL Server 2005

I get an "Class not registered" error whenever I attempt to connect to the integration services on sql server 2005 from within SQL Managment Studio 2008. Is there a workaround? or do I have to downgrade to SQL managment studio 2005? ...

How to create a XML Schema Collection and use it in Fluent nHibernate?

I'm looking forward to generate our database script by using the script generated by nHibernate. We use Fluent nHibernate to create our mapping. In our original database design, there is a few xml columns that use the following schema: CREATE XML SCHEMA COLLECTION LocalizedValue AS N'<xs:schema attributeFormDefault="unqualified" eleme...