sql-server

name of tables & views in stored procedure in sql server 2005

Hi All, I have a stored procedure, I want to know the name of the tables and views use in that stored procedure, can any one suggest how can I do so. Thanks in advance. ...

Is the code available that SQL Server uses to fill sys.sql_dependencies?

My current client is struggling with their release process. It's a bit complex and a little uncontrolled. I'm trying to fix the process problems, but in the meantime it would be helpful if I could put together a utility that could scan their scripts, look for dependencies, and generate the order in which those scripts need to run. Rathe...

Assigning a delimited string to a variable

Hi I have this requirement: Pipe delimited text file to a table (TEST) in the SQL db - yes this is fine Now i need to group the results based on the primary key and return the result set as a delimited (pipe deliited string) to a variable. This variable is then used as an input parameter to a stored proc which later processes stuff. ...

Efficient way to compare for a NULL or value for a column in SQL

What's the efficient way to check for a null or value for a column in SQL query. Consider a sql table table with integer column column which has an index. @value can be some integer or null ex: 16 or null. Query 1: Note sure, but it seems one should not rely on the short-circuit in SQL. However, below query always works correctly when ...

Development --> Production server(scripts for change in table structure)

Whenever i move the changes from development to production server. I Drop scripts for stored procedures, functions. Then generate new scripts for stored procedures, functions. But for new tables creation, i only create scripts. But for change in the table structure, i make a note of change in the fields(if they are less), OR create a a...

Paging Large Datasets - SQL Server (Best Practice)

I am interested in what the best practices are for paging large datasets (100 000+ records) using ASP.NET and SQL Server. I have used SQL server to perform the paging before, and although this seems to be an ideal solution, issues arise around dynamic sorting with this solution (case statements for the order by clause to determine colu...

Connecting to a SQL Server on the Web

My company had a machine running SQL Server hosted by a company specializing in such. We have an .NET application that connects to it. Recently the decision was made to bring the machine in house. If we use the internal IP of the machine to connect, it works. When we go to an outside network and use the machine's external IP, it fail...

Sql Union Query Help

Hi All, I need a little help writing a query. I have this data... vDir iNumber North 19 North 27 North 29 North 31 South 46 South 49 South 51 South 61 I need to query the data and have an output something like this vDir iLowNumber iHiNumber North 19 27 North 27 29 North 29 ...

videos for teaching sql server 2008

I must find the best sites which will have free download videos for teaching sql server 2008 and this is one part of my project. I have found some links but I also need your help. ...

Is this lookup (association) table correct? (many to many relationship)

CREATE TABLE jokecategory ( jokeid INT NOT NULL, categoryid INT NOT NULL, PRIMARY KEY (jokeid, categoryid) ) DEFAULT CHARACTER SET utf8; especially PRIMARY KEY (jokeid, categoryid)? or is there a better way to write this? Thank you in advance;-) ...

How can I obtain the group of "dirty" rows or cells from a DataGridview?

I am working with a DataGridView filled up from a view in my database. Being a view (maybe I'm wrong) I can't use the TableAdapter.Update() method so I need to know the altered cells from the DataGridView so I can update the values in their respective tables programatically. Can you help me? ...

How to combine data from different columns from different databases from different vendors into one table?

Hello, Say i have a table named tbl1 in mysql :- bookid int name varchar(20) price int categoryid int And then i have a 2nd table, tbl2 in Oracle :- pubid int name varchar(20) addr varchar(50) I want to combine these two into MS Sql Server 2008 named tbl3 whose structure should be :- bookid int name varchar(20) price int pubid in...

Filtering bad data in SQL Server 2005

Using SQL Server 2005 I have a table with the following columns id name date value I would like to select all rows from the table where there are not four consecutive zeroes by date. How would I do that? Below is an example of what I mean. id name date value 1 a 1/1/2010 5 2 a 1/2/2010...

Cast Stored Procedure Result as a Table? (SQL Server 2008)

Hey all, I currently have a stored procedure that runs a complex query and returns a data set. I'd like to cast this data set to a table (on which I can perform further queries) if at all possible. I know I can do this using a table-valued UDF but I'd prefer to avoid that at this point. Is there any way I can accomplish this task? T...

IDENTITY_INSERT is set to OFF - How to turn it ON?

I have a deleted file archive database that stores the ID of the file that was deleted, I want the admin to be able to restore the file (as well as the same ID for linking files). I do not want to take identity_insert off the entire table, as the increment by one works great. In my insert to TBL_Content store procedure I have somethin...

How to convert newlines (replace \r\n with \n) across all varchar and nvarchar fields in a database

I am recovering from a bug in a system I built where I did not take into account that IE generates Windows-style newlines (\r\n) and other browsers generate Unix-style newlines (\n) when posting HTML forms with text areas. Now I need to convert all Windows-style newlines (\r\n) to Unix-style newlines (\n) throughout the varchar and nvarc...

activerecord-sqlserver-adapter on Ubuntu

I followed the instructions found here to get my rails app to communicate with SQL Server on Ubuntu 10.04 http://wiki.github.com/rails-sqlserver/2000-2005-adapter/platform-installation-ubuntu-2 All the tests documented there have passes except the when I try script/sconsole I was able to make a db connection in irb In my app I have a ...

For XML length limitation

Hi I am trying to concatenate results of some string data in a query using XML PATH See query below.What happens is that the XML concatenated column statement gets truncated.Seems like there is a limitation on maximum length.How do I overcome this. select SUBSTRING(statement,1,len(statement)-2)+';' from( select 'update '+tab.table_na...

SQL Full-Text-Search returns no results when any noise words are in search string.

I have an asp.net web page used to search for company names in our database using FTS. They enter the company name in a search box and submit. First I trim any leading or trailing spaces, then i replace each internal space with " NEAR ". So a search for: "The Association of Lefthanded Picklepickers" Is fed as: "The NEAR Associ...

Please help with a database driven mail merge application embedded in a .net web application.

I am trying to have letter templates (word documents) that are stored in sql server VarBinary(max) to be accessed via a web application where they will be edited and saved back to sql server by directors of our company. Then various managers will be able to select an existing template (word document), make any additions, and mail merge ...