sql-server

Want to script all objects which depend on a SQL Server table

The 'View Dependecies' shows all the objects which depend on a table in SQL Server. Now how do I use SSMS to script all these objects in one command? Is there a free tool that does this? ...

SQL Server 2000 stored procedure branching with parameters

I want to create a stored procedure. If the parameter is -1 then there should not be a where clause on that column else there should be a WHERE clause. What's the best way to do it without a lot of IF branching? I checked the archive. There are a few similar questions but not exactly the same. CREATE PROCEDURE report ( @site int, ...

Select from multiple tables matching multiple criteria

Hello, I am working with 3 tables, trying to pull a list that match certain criteria. I need a list of companies from the companies table, that have an active opportunity (iactive is 1 in opportunities table) AND have a record in the notes table of type order or order2. Companies Table +------+------------------+ | cid | ccyname ...

What is wrong with this SQL?

The SQL is: execute ('delete from HttpRequests where Date < ''2009-08-' + convert(nvarchar(max), 0) + '''') The error is Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'convert'. Commenting out the convert part removes the error. Whats wrong? ...

Querying a view vs tables in SSRS Dataset

Is there a best practice when it comes to using Datasets in SSRS? Should I be writing a query for the dataset that pulls directly from tables, or should I be creating a view in the source database and then querying the view via the Dataset? I understand there are some scenarios where the view would be better (centralizing a view for use...

SSRS show value only on last page in body of report

I'm attempting to show a sum in a table footer on a report. It will be in the body of the report and can't be in the header or footer. The table footer repeats on each page but should show the sum only on the last page. It will show another piece of text on all other pages. Is this possible? Additional pieces of information: The d...

SQL Server Trigger switching Insert,Delete,Update

Hello is possible to switch between DML commands/operations (Insert,Delete,Update) on Trigger Body?, I try to snippet some T-SQL for understand me better : CREATE TRIGGER DML_ON_TABLEA ON TABLEA AFTER INSERT,DELETE,UPDATE AS BEGIN SET NOCOUNT ON; CASE WHEN (INSERT) THEN -- INSERT ON AUX TABLEB WHEN (DELE...

Linq Query Returns Incorrect Result Set

I have a very complex Linq to SQL query that returns a result set from a Microsoft SQL Server database. The query is created using syntax similar to: Dim db as MyDataContext = MyGetDataContextHelper() Dim qry = From rslt in db.MyView Select ColumnList If userParam1 IsNot Nothing Then qry = qry.Where(lambda for the filter) End If e...

Query to show result in the charts.

Hi, I have to implement charts in my application. Suppose i have a table structure DECLARE @SONGS TABLE ( [ID] INT IDENTITY, [SONGNAME] VARCHAR(20), [CREATEDDATE] DATETIME ) INSERT INTO @SONGS SELECT 'SONG1','20091102' UNION ALL SELECT 'SONG2','20091103' UNION ALL SELECT 'SONG3','20091107' UNION ALL SELECT 'SONG4'...

(Probably) Simple SQL Server cursor question

I need to call two stored procedures in sequence via ODBC in PHP: #run stored procedure 1 $query = "Shipped_Not_Shipped_Rep ".$_GET['rep_id']; $result = odbc_exec($dbh, $query); odbc_result_all($result); #run stored procedure 2 $query = "Shipped_Not_Shipped_Account ".$_GET['account_id']; $result = odbc_exec($dbh, $query); odbc_result_a...

SQL Server Code Search Tool.

I I wanted to search all stored procedures for the occurence of a substring "x", can I do this in SQL 2000? 2005? 2008? ..without any add-ins? If not, what are the best available free add ins for each? Sorry. I should have mentioned that I am aware how to use sysobjects data to do this. But it seems to me there should be a nice GUI i...

SQL Query to generate balance

I have one table named LedgerReport which contain customer name,sales bill number and amount and i have to generate the balance of customer wise one by one row without using the cursors and i hav send u the sample report below so please send me some suggestion to solve my problem... Create Table LedgerReport ( Customer Nvarchar(6...

TFSBuild.Proj and Manual SQL Server Work Help?

Using the VS 2008 GDR update, I have created a database project. I have created a SQL Server deployment package. I have created a database unit test. Using some wizards, the stuff got into my tfsbuild.proj file so near the end of the automated build process a database is created. I lack a little control of the whole process, I now see....

Entity Framework with SQL Server 2000 (APPLY Operator) issue

Hello, I have a simple Linq query below: var seq = (from n in GetObjects() select n.SomeKey) .Distinct() .Count(); This query works find with SQL Server 2005 and above. But, this start to give headache when I hooked the EF to SQL Server 2000. Because EF is using APPLY operator which only SQL Server 200...

How do i merge two or more rows based on their foreign key?

I have three tables which are: A(a1, a2, a3) //This tbl (Table) can have multiple instances of a1, but cause of its dependence on b1, //we have a unique record each time B(b1, a1, b2) //tbl C has a relationship with tbl B through b1. b1 can also have multiple instances, but //sometimes a number of unique records in this table can ti...

Trying to connect Access 07 for use as a front end to a SQL Server 2008 Express database.

Relevant background- I'm a noob working my brains out for over a year into trying to make a database in MS SQL Server 2008 Express with the end idea for the front end being Access. After tons of reading and slaving over my schemas and three major revisions I'm finally ready to connect it to Access and I'm just striking out all around. T...

Persisting to SQL Server 2008 using stored procedures, JPA and Hibernate

We are implementing a web page to maintain an organisational structure. The structure is stored in SQL Server 2008 and uses the new HierarchyID data type. Because we have had problems getting JPA and Hibernate to play with this new data type we have decided to use views and stored procedures to abstract away this data type. So we want to...

Static SQL Server Indexes

Is it possible to create unclustered indexes in SQL Server 2005 that are not updated as data is changed (insert/delete/udpate) so I can ensure a stable set of data to report on? Our data is changing frequently an I want to be able to snapshot it at a point with out having a column to show the latest change date/time and only selecting d...

dbGo or dbExpress for Delphi 2010 with Microsoft SQL Server

Hi Everyone, I am migrating to Delphi 2010 and I am using Microsoft SQL 2000 (Planning on upgrading to SQL2008). I have been using BDE all along and wondering if I should use dbGo (ADO) or dbExpress with my future application. Can someone explain to me the pros and cons for using either one? Thanks a lot. ...

SQL Server: Stopping Queries Externally

Hello all, I run queries using SQLCMD utility via PHP and I wanted to know if there was a way to stop queries or scripts that I have executed via another SQL command by passing the process ID or something. I also make use of the PHP Driver for SQL Server would it be easier to do this way? Or is none of this possible - once a query run...