sql-server-2005

Query about designing relationships in Sql Server's management studio interface

Imagine I have two tables: Manager, Player.This is for a football team, where several players can play for one manager only and a manager manages several (11) players. When designing the relationship in Sql Server, at the time the popup window comes up with the properties for the relationship, does it matter which side the tables are? ...

get new SQL record ID

How can I get back the autogenerated ID for a new record I just inserted? (Using ASP classic and MSSQL 2005) ...

How do I join two tables from two different databases?

Is there any way to use a query and join two tables that is in two different database on the same server for DbVisualizer? I used the following for the SQL server Select * from table union select * from datbase.dbo.table2 I tried this for the DbVisualizer, and it didnt work. How do I do this? ...

Convert varchar in format mon-yy to datetime in SQL server

Is there a simple way to convert a date stored in a varchar in the format mon-yy (e.g. "Feb-09") to a datetime which will convert any invalid values to null. I'm currently using string manipulation combined with a case statement but it's rather cumbersome. ...

Cannot connect to SQL Server remotely or locally after reboot

After some network maintenance last weekend, we had some trouble with our development server which led to us restart it. Some updates were installed during the restart, which may or may not have been a factor. Since then, we have been unable to connect to SQL Server 2005, even locally via Management Studio. Depending on the protocol used...

Using T-SQL with Oracle DB

I am using T-SQL query directly in Microsoft SQL Server Studio's Query window against to a large Oracle DB, and my SQL server is 2005. I have created a linked server as myOracleServer. By using the following T-SQL query: SELECT COUNT(*) FROM myOracleServer..owner.myTable WHERE id = 1000 AND Dt = '2009-02-26' It take more than 1 minut...

Search for a string in an all the tables, rows and columns of a DB

I am lost in a big database and I am not able to find where the data I get comes from. I was wondering if it is possible with SQL Server 2005 to search for a string in an all the tables, rows and columns of a DB? Does anybody has an idea if it is possible and how? Thanks! ...

SQL Express remote access

Is there any way to install SQL Express 2005 silently while configuring to allow remote access, or must the configuration be done with the SQL Server Management Studio UI? ...

How to pass result out of exec a query on oracle db?

I have the following call to Oracle db: DECLARE @myCount int; DECLARE @sql NVARCHAR; SET @sql = N'SELECT COUNT(*) FROM owner.myTable'; EXEC (@sql) AT oracleServer -- how to get result count to @myCount? where oracleServer is a linked server to Oracle. How can I pass the count result out to a varaible @myCount? I tried: EXEC (@sql, @m...

MSSQL Server Management Studio (SSMS) 2005 New Query Template

How do I change a default "New Query" template in SSMS 2005? ...

How to pass parameter values to a T-SQL query

I am using the following T-SQL query in SQL server 2005 (Management Studio IDE): DECLARE @id int; DECLARE @countVal int; DECLARE @sql nvarchar(max); SET @id = 1000; SET @sql = 'SELECT COUNT(*) FROM owner.myTable WHERE id = @id'; EXEC (@sql) AT oracleServer -- oracleServer is a lined server to Oracle I am not sure how to pass the input...

Inserting records at a time

I have 2 table TableA and TableB I want to insert all records at a time from TableA to TableB if the records are not in TableB Please help thank you ...

Can Windows Authentication be used with PHP on IIS for ODBC connections?

Is it possible to use the users windows authentication (setting in iis) for database connections in PHP? This is possible in the .NET world through a technique called "impersonation". Does this also exist in the PHP/IIS world? EDIT: The Database I am using is MS SQL Server 2005. ...

SQL Group By question SQL Server 2005 CE

Hi everybody, I'm having a problem with an sql query that i use for my mobile application which uses sql server 2005 ce. I'm not so good with t-sql, so have a problem with this query SELECT TP.ID_TASK_MASTER, TP.ID_PROBLEM, TP.ID_TASK_PROBLE, P.DS_PROBLEM, TP.SW_HASOK, TP.SW_HASNOK, TP.SW_HASTOK, TP.SW_HASVALUE, TP.NO_...

How to make single where condition for this SQL query?

I am using MSSQL 2005 Server and I have the following SQL query. IF @CategoryId IN (1,2,3) BEGIN INSERT INTO @search_temp_table SELECT * FROM (SELECT d.DataId, (SELECT [Name] FROM Category WHERE CategoryId = d.CategoryId) AS 'Category', d.Description, d.CompanyName, d.City, d.CategoryId, d.CreatedOn, d.Rank, d.vot...

How to display relevant record first using FULLTEXT in SQL ??

I am using the FULLTEXT in my sql query to search the records. SELECT * FROM (SELECT d.DataId, (SELECT [Name] FROM Category WHERE CategoryId = d.CategoryId) AS 'Category', d.Description, d.CompanyName, d.City, d.CategoryId, d.CreatedOn, d.Rank, d.voteCount, d.commentCount, d.viewCount FROM Data d ...

Calculate execution time of a SQL query?

I am providing search functionality in my website, when user searches a record then I want to display the time the query taken to get the results same as google does. When we search anything then google displays how much time it takes to get results? For this I have declared a @start variable in my SP and finding the difference in the e...

Join Table on xml column.

I have 2 tables as follows on Sql Server 2005 database Request(RequestId int, Filter xml) DataTable(Id int,.....) The filter column has a list of ids from datatable as xml for e.g. 1013 Now I want to select the data from DataTable that match the ids in the filter xml. Here is what I have come up with select d.* from request ...

Is there any size limit for the values returned from a Stored Procedure in SQL 2005?

I am trying to return Xml value from SQL Server 2005 using For Xml. Is there any limit in the size of xml returned from SQL Server? I will be using ExecuteXmlReader to get the value in my C# code. Also, is there any limit on the data that can hold in an XmlReader? Any thoughts... ...

What is the best way to generate XML from the data in the database?

If I have thousands of hierarchical records to take from database and generate xml, what will be the best way to do it with a good performance and less CPU utilization? ...