sql-server-2005

Retrieve input and output parameters for SQL stored procs and functions?

For a given SQL stored proc or function, I'm trying to obtain its input and output parameters, where applicable, in a Winforms app I'm creating to browse objects and display their parameters and other attributes. So far I've discovered the SQL system function object_definition, which takes a given sysobjects.id and returns the text of t...

Query Results Not Expected

I've been a CF developer for 15 years and I've never run into anything this strange or frustrating. I've pulled my hair out for hours, googled, abstracted, simplified, prayed and done it all in reverse. Can you help me? A cffunction takes one string argument and from that string I build an array of "phrases" to run a query with, attem...

deleting records from multiple tables at a time with a single query in sqlserver2005

Hi I wanna delete records from child tables as well as parent table with in a single query. please find the query given below. here response header is the primary table and responseid is the primary key. DELETE FROM responseheader FROM responseheader INNER JOIN responsepromotion ON responseheader.responseid = responsepromotion....

Searching with FullText in SQL Server 2005

I have a search that uses fulltext searching in SQL Server 2005 to do exact matches first, then does partial matches, etc... However, the way I'm doing it seems overkill... I basically need to do an exact match against a Title, keyword & a whole load of other fields (I've not put them in the examples below), but the order for search res...

Expanded securityadmin

I'm aware that sysadmin is documented as the server role necessary for creating logins (SQL/Windows-integrated); nevertheless, I'm tasked to find out if there's any other server role (built-in or otherwise) that can be used. To be specific, I'm looking to setup one or two logins with access to create logins, create [database] users, as...

SQL Server 2005 - Find minimum unused value within a range

I have a situation similar to the following question: Insert Data Into SQL Table Where my scenario differs is that I have a non-auto-incrementing primary key field that can have a range between 1000 and 1999. We only have about a hundred values in it thus far, but the maximum value has already been taken (1999), and there are gaps in t...

How to use CASE in SQL , Syntax Error being shown

I am trying to retrieve some records from table based on my query but it shows me an error Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '> select vd.LedgerId,(CreditAmt-DebitAmt) AS NET, CASE NET WHEN NET > 0 THEN 'Debit' WHEN NET < 0 THEN 'Credit' ELSE 'Nil'End from dbo.vdebit vd INNER JOIN dbo.vCredit vc ON vd....

SQL Server 2005 I get "The database is not accessible"

I have a computer working as a server with many SQL Server 2005 databases in it since two years ago. Today, I don't know why, when I try to connect locally to any of the databases it gives me that error. It fails even if I'm logged in using Windows Authentication or as 'sa' user. It just wouldn't let me access the databases' info. Coul...

How can I get a SQL Server 2005 compatible backup from SQL Server 2008 database?

I have a sql server 2008 db, I want to restore its backup to a 2005 version. Is there any way for this work? Note: I can't make a script from my db and run it. ...

How to recover a deleted row from SQL Server 2005 table ?

Hi Gurus, How to recover a deleted row from SQL Server 2005 table ? Thanks, Ahmed. ...

Materialized Query Table in SQL Server 2005

In DB2 there is a support for Materialized Query Table (MQT). Basicly you write a query and create a MQT. But the difference from View is that the query is pre-executed and resulting data is stored in MQT and there are some options when to refresh/syncronize the MQT with base tables. I want same functionality in SQL Server. Is there a w...

How to establish secure connection between java application and database?

In an interview, Interview asked me an question : The communication between our application and the remote database must be done with https (more secure). How could you do it? I didn't find any clue for this question in google also. How to establish secure connection between java application and database? Please help me. ...

SQL 2005: Select top N, group by ID with joins

I'm having real difficulty with a query involving 3 tables. I need to get the 3 newest users per department grouped by department names. The groups should be sorted by the users.dateadded so the department with the newest activity is first. The users can exist in multiple departments so Im using a lookup table that just contains the ...

SQL Server 2005: Invalid object name exception

In VS2005, I am using a DLL which accesses a SQL Server. The DLL returns a SQLException Invalid object name 'tableXYZ' but tableXYZ is a table in the database. Should it be looking for dbo.tableXYZ instead? Is this a permissions issue with the login being used? ...

How to export into word format using Reporting Services (SSRS)

Using Reporting services in SQL Server 2005 in asp.net with c#, how can we export reports in word document? Thanks In Advance.!! ...

Using IF in T-SQL weakens or breaks execution plan caching?

It has been suggest to me that the use of IF statements in t-SQL batches is detrimental to performance. I'm trying to find some confirmation of this assertion. I'm using SQL Server 2005 and 2008. The assertion is that with the following batch:- IF @parameter = 0 BEGIN SELECT ... something END ELSE BEGIN SELECT ... something e...

Creating a SQL update query based on multiple columns and records in same table

I have got a table which contains 5 column and query requirements: update row no 8 (or id=8) set its column 2, column 3's value from id 9th column 2, column 3 value. means all value of column 2, 3 should be shifted to column 2, 3 of upper row (start from row no 8) and value of last row's 2, 3 will be null For example, wit...

Stored procs breaking overnight

We are running MS SQL 2005 and we have been experiencing a very peculiar problem the past few days. I have two procs, one that creates an hourly report of data. And another that calls it, puts its results in a temp table, and does some aggregations, and returns a summary. They work fine...until the next morning. The next morning, s...

An expression of non-boolean type specified in a context where a condition is expected, near 'Id',in SQL Server2005

Hi All, I am new to ADO.net and SQL Server 2005. I created one table TABLE1 with id(pk),name,group and I am trying to update using UPDATE TABLE1 SET name="stack" where id=2 then it giving bellow error An expression of non-boolean type specified in a context where a condition is expected, near 'Id'. ...

SharePoint web part - SQL statement not reflecting change

I recently wrote a SharePoint web part in C# that pulls information from a SQL database with some parameterized queries based on user selections. This involves a list of customers in a dropdownlist that is populated from a datareader like so: while (dr.Read()) { string customerNameAndCity = dr.GetSqlString(1).Value + " - " + ...