sql-server-2005

SQL Server XML Data Type query issue.

Please see below SQL Server 2005 script Declare @xmlData XML SET @xmlData = '<?xml version="1.0"?> <bookstore xmlns="http://myBooks"&gt; <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0"> <title>The Autobiography of Benjamin Franklin</title> <author> <first-name>Benjamin</first-name> <l...

SQL Server 2005 loading data from an external server

Have a new project with the following setup and requirments:- My client has a MSSQL 2005 server (A) in their office. Their vendor has a MSSQL 2005 server (B) in another part of the world, which contains real-time transactional data. My client wants to load the data from (B) to (A) on a daily basis during non office hours. They have data...

How do I create a schema like .dbo in SQL Server [2005]

I am creating a database in SQL Server 2005 and cannot remember the "CREATE SCHEMA" statment, if that's it, to create a new schema similar to ".dbo". I did it last night, but I cannot remember how and cannot find the article. What I'm trying to accomplish is a database organization like that of the AdventureWorks database where the tab...

Element RECORDCOUNT is undefined in "yyReslt"

I have a query that is being used in a coldfusion file (MX)( on the Production since 10 yrs ). I have used this application/files since 4 months,successfully. But now ,Suddenly I am getting the error Element RECORDCOUNT is undefined in "yyReslt" Will this occur if the Database connection is slow/improper? ...

How can I get the last inserted primary key?

I'm using SQL Server 2005 with a table with a primary key field with the type varchar(40). I have to get the last inserted record's primary key value. I have tried scope_identity but it is not working. How can I get this? ...

Handling decimal item quantities

I am currently working on developing a program that stores Quantity as a decimal with four digit places for the very small minority of products that are sold in part (eg 100ml liquid being sold in variable amounts like 1mg-3.5mg). I dislike this design as it causes problems for the entire program in deciding how to present the quantity a...

database table will not drop (or show it's inputed data)

hi, if i apply a sql query statement to this table "select * from context.tablename", all i see is the "Executing query.." message and nothing else hapens. I also can not truncate or drop this table. It prevents me from even dropping vhole database. Is it possible, that this problem is caused by inserted data into this table??? I'm usi...

Cannot connect to the sql server .

i am having management stdio 2005 in my machine and im tring to connect to sql server 2008 i'm receiving the following message as the inner exception . {"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is ...

SQL insert error

Below code saying error incorreect syntax near "Main" INSERT INTO tbl ( 'Week', Main, a, b, c, d, e ) Select 'Week', Main, a, b, c, d, e FROM tbl_link ...

Using SQL Server Agent to Run a Remote SSIS Package Programmatically on the Server

Based on the example here from MSDN, how could one provide SSIS package level variables if one were to invoke the package via "sp_start_job" procedure? Here is the example code from MSDN: Dim jobConnection As SqlConnection Dim jobCommand As SqlCommand Dim jobReturnValue As SqlParameter Dim jobParameter As SqlParameter Dim jobResult As ...

SQL Server: inline conditional convert with XML?

I need to convert data in plain text columns into xml columns. However, not all of the content is valid XML, so I need to ignore any rows with invalid XML. Is there a way I can filter out the invalid data either using some sort of inline conditional convert or something in the WHERE clause? ...

foreign keys on table from different database

I have two databases in SQL Server and i have a common table for both the databases an important big table which holds the foreign keys to other tables. The problem is the Table is in DatabaseA, and I need to refer foreign keys to this table from DatabaseB. I know SQL doesn't support cross database referential integrity so what's the be...

unique count of the columns ?

i want to get a unique count of the of multiple columns containing the similar or different data...i am using sql server 2005...for one column i am able to take the unique count... but to take a count of multiple columns at a time, what's the query ? ...

Access sometimes jumps to existing record on save new record - Access2k FE/SQL2005 BE

Hi, this is my first question on SO, am really posting this out of desperation after searching around a lot for an answer and trying a few different things with no success. I have an Access database where I have recently migrated the tables to SQL 2005, Access continues to function to the users as a front-end providing forms, reports, ...

Date Column was created

Hi, Do you know if there is a way to get the creation date for a SQL Server 2005 table column? I tried the sp_columns [tablename] to get some table information but no luck. Thank you. ...

Can you tell SQL Server not to return specific rows?

We have a database where contacts are only soft-deleted, i.e. we set a bit named deleted to true. The API handles this, but sometimes you need to run queries directly against the database and it's easy to forget that bit, and export contacts that are actually deleted. It's not a big problem, because I'm used to the system, but if I'm on ...

prevent an SQL Server Admin from changing a user in the database?

Is it possible prevent an SQL Server Admin from changing a user in the database? The case is that a user which is created by an application has ReadOnly rights on the database. The Server Admin of a customer should not be allowed to change these rights or other settings of that user and database. ...

Sql - format phone number

HI , i have table in the db with phone number column the numbers look like this 123456789 i want to format tham to 123-456-789 thanks!!! ...

How Do I create a log using performance monitor in SQL?

A company I deal with have their own server, and a couple of sites using SQL server 2005 on it. They are getting random, intermitten freezes and its pointing to SQL Server so the company who they got the server from said to "create a log using performance monitor in SQL" I have RD Access... Is this a simple setting I just need to put ...

SQL Server Syntax to select two rows of data and overwrite values that are different from the first row

Hi, I have a table that looks like the following: id, Name, LinkBackId, Param1, Param2, Param3 1, "Name1", NULL, 10, 20, 30 2, "Name2", NULL, 10, 20, 30 3, "Name3", 2, 14, NULL, NULL The LinkBackId is important here because this is associated with the id that is also in th...