sql-server-2005

Creating Stored Procedure Syntax, relating to use of GO

Does anyone know why. CREATE PROCEDURE My_Procedure (@Company varchar(50)) AS SELECT PRD_DATE FROM WM_PROPERTY_DATES WITH (NOLOCK) WHERE PRD_COMPANY = @Company GO Gives me an error message in SQL management studio: Msg 102, Level 15, State 1, Procedure My_Procedure, Line 1 Incorrect syntax near 'GO'. ...

How to add data to two tables linked via a foreign key?

If I were to have 2 tables, call them TableA and TableB. TableB contains a foreign key which refers to TableA. I now need to add data to both TableA and TableB for a given scenario. To do this I first have to insert data in TableA then find and retrieve TableA's last inserted primary key and use it as the foreign key value in TableB. I t...

TSQL: Select from set of columns with lowest positive value

Example Schema: RowID Quantity ModifiedPrice GroupPrice CustomPrice SalePrice ---------------------------------------------------------------------------- 1 5 20.00 0 15.00 17.00 2 2 14.00 7.00 22.00 0 3 9 10.00...

Determine which user deleted a SQL Server database?

Hi, I have a SQL Server 2005 database that has been deleted, and I need to discover who deleted it. Is there a way of obtaining this user name? Thanks, MagicAndi. ...

Strange "Invalid column name" error when executing SP

We have an SP in which we build a query and then execute the query by using the exec(@select) call, where the variable that holds the SQL query as it is constructed is @select. I have been assigned a request to add a new column to the resultset returned by the SP. This new column should not be returned in all circumstances, but only und...

T-SQL: Cannot pass concatenated string as argument to stored procedure

Scenario: Need to pass n arguments to a stored procedure. One of the arguments is of type varchar(x). That varchar argument needs to be constructed from a handful of other varchar variables. This problem uses SQL Server 2005, but this behaviour applies to all versions of SQL Server. Setup: DECLARE @MyString varchar(500), @MyBar varchar...

Team Foundation Server reporting stops refreshing after adding a CMMi repository

Hi… I have this problem and did not find in the site a case like mine. Here is the thing. I created a TFS 2008 with the scrum template (Conchango). It was a clean install (a fresh OS, a fresh SQL Server, a fresh machine, etc…). So everything worked like a charm. I created 3 Scrum repositories, assigned permissions, uploaded files and ...

Incorrect syntax near the keyword 'table'.

I am receiving this error. What I am doing is trying to take data from one table and one db and place it into another db and table. The tables are not exactly the same. I am using a FETCH cursor, so I fetch the first row from db1 table and then place each column value into declared variables. Then I run the insert statement into db2 tabl...

Transaction Isolation Level Scopes

What are the scoping rules for transaction isolation levels in SQL Server 2005? I know what the different levels mean, but not how to properly apply them outside of a manually run script. I can't find a guide for practical use in production-quality code. Obviously, the scope begins when you use a command like this: SET TRANSACTION ISOL...

What is the jTDS JDBC Connect URL to MS SQL Server 2005 Express

I'm trying to connect to a MS SQL Server 2005 Express database that is running on the local host from a java program. I have tried the same connect URL (below) that I used on another system (same jave code) that was running MS SQL Server 2000. But that does not work. jdbc:jtds:sqlserver://127.0.0.1:1433/Finance Any ideas? ...

What are the major differences between Sql Server 2005 and Sql Server 2008?

Duplicate Advantages of MS SQL Server 2008 over MS SQL Server 2005? What are the major differences between Sql Server 2005 and Sql Server 2008? How could I convince my organization to invest in Sql Server 2008? For me, one major aspect that I see is that they have a good framework to programmatically generate SSIS packages with the us...

Rows to Columns using Sql Query

hi i have a table with columns as Cost Rate Repair 12 Repair 223 Wear 1000 Wear 666 Fuel 500 Repair 600 Fuel 450 Wear 400 Now i want this data as Repair Wear ...

How do I get revolving last 12 months in T-SQL 2005?

At the moment I use DATEPART(yy, MY_DATE) = DATEPART(yy, GETDATE()) to get Year-To-Date details and have to convert it into the revolving last 12 months. How would I do that? ...

C# Loading xml data from xml file to Sql server

This is PM.xml 0023 10 Ad GGG 2009-06-08 06:31:20.000000 S ' How can I load data(ReqID,Priority, OId,OD...) in PM.xml file ->MS SQL SERVER 2005 I use C# language. ...

T-SQL Grouping rows from the MAX length columns in different rows (?)

Hello, i'm trying to come up with a way to combine rows in a table based on the longest string in any of the rows based on a row key example CREATE TABLE test1 (akey int not null , text1 varchar(50) NULL, text2 varchar(50) NULL, text3 varchar(50) NULL ) INSERT INTO test1 VALUES ( 1,'Winchester Road','crawley',NU...

SQL objects that use an index

Is there a way to see what SQL objects from one data base use a certain index. But I do not want to have to see the execution plan for every object because I have a lot of stored procedures and views PS. It's for SQL 2005 ...

SQL Server stored procedure issue calling another stored procedure

Here's a issue I have with a stored procedure (using SQL Server 2005), inside this stored procedure it calls another stored procedure putting the data into a temp table. INSERT INTO #tmpTable (Column1, Column2, Column3) EXEC psp_rptInsideStoredprocedure 2 This inside stored procedure has a mode parameter that determines which columns...

Simplest way of updating SQL Server 2005 from a REST web service

We have a job management application running (Access) with the database in SQL Server 2005. A third party is going to provide job information to us, which they make available as XML via an SSL web service using a REST style interface. The service needs to be polled automatically on a regular - 5 or 10 minutes - basis. The XML data nee...

Converting from globalized date/time format (maybe ISO8601) to SQL Server datetime type

Is there a string format to represent a datetime that SQL will be able to parse and convert into another offset (EST -> UTC for example). I have a string from the user such as: declare @p1 varchar(50); declare @utcDateTime datetime; set @p1 = "2009-06-26 14:30:00.000Z-4:00"; -- could be ISO8601 -- what do I do here to convert @p1? ...

Is there a way I can send a NULL value to a SQL stored proc through XML?

I'm wondering if there is a way I can send a NULL or DBNull.Value from my C# data service to a stored proc through some configuration xml parameter. In the proc, I want to pull some values out of the xml as a bit but because the UI allows for a third state, the bit value coming in from the xml can be NULL in which case I want to ignore ...