sql-server

How to filter a table by T_SQL in SQL Server 2005, using a specific time for a column of "DateTime" datatype

hi How to filter a table by T_SQL in SQL Server 2005, using a specific time for a column of "DateTime" datatype? Thank you ...

City, State, Zip, Country list/script for sql server table

I have been searching around for the best source for City, State, Zip, Country to use in an application. I have found the set at GeoNames.org and it seems very comprehensive. However there is not a simple import into SQL Server. I also believe the USPS has something similar. Does anyone know a good reliable source that is easily imp...

openning sql connection from iis7?

i created an asp.net website with visual studio 2008 sp1 and in the code i use sql connection to reach a data base in my sql server 2008. it all wiorks great but then i wanted to deploy the website in iis7 (windows 7) which was hell to discover how to do it- ( i added a virtual directory and converted it to an application and only then ...

Open new SQL Server connection in PHP

I have an open SQL Server connection and need to open and close another while maintaining the first connection. I CANNOT hold onto the resource ID for the original. Connection A (may or may not be open) Open connection B Perform a few queries using connection B Close connection B Continue working with connection A ...

Looking for a General "Minimum" User Defined Function

I created the following function to simplify a piece of particularly complex code. CREATE FUNCTION [dbo].[DSGetMinimumInt] (@First INT, @Second INT) RETURNS INT AS BEGIN IF @First < @Second RETURN @First RETURN @Second END However, it only works for the INT datatype. I know I could create one for numeric and possibly for Varc...

How can I Reapeat TextBox in every report page?

I have a client report (rdlc) and want to repeat some textboxes in every pages. I can't put these textboxes in header. I bind data to these textboxes, so I can't put these at header. Is there any solution for this? ...

How pass a list of values to compare in a SQL Function in SQL Server 2008?

I have an SQL Function with the following SQL within: SELECT StockID FROM (SELECT DISTINCT StockID, ROW_NUMBER() OVER(ORDER BY DateAdded DESC) AS RowNum FROM Stock WHERE CategoryCode LIKE @CategoryID) AS Info WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @maximumRows) - 1 I have a Parameter @CategoryID - however I need to...

Does Physical File Deframentation contribute to Index Fragmentation?

I have a sysadmin who wants to frequently defrag my hard drives on my servers. Does physical file defragmentation cause my indexes to become more fragmented? Should I rebuild my indexes after ever disk defrag? I know clustered indexes might benefit from disk defragmentation, but what about the nonclustered ones? That's what I am mostl...

Hash Code in SQL Server?

I am trying to solve a unique problem. Thanks for any help with this. Is there an easy way to generate some kind of a hash code for a record based on several of its field values? I thought about just creating a view with an extra column that concatenates all of the values that I want to check, but I'm checking to see if there is a bet...

Doing a join across two databases with different collations on SQL Server and getting an error.

I know, I know with what I wrote in the question I shouldn't be surprised. But my situation is slowly working on an inherited POS system and my predecessor apparently wasn't aware of JOINs so when I looked into one of the internal pages that loads for 60 seconds I see that it's a fairly quick, rewrite these 8 queries as one query with J...

Left Join and Where Clause

Query - Select * FROM tbl1 LEFT OUTER JOIN tbl2 ON tbl1.id = tbl2.id AND tbl2.col2 = 'zyx' AND tbl2.col3 = 'abc' WHERE tbl1.col1 = 'pqr' Here I'm doing left outer join and using 'and' along with join. (First I was using joins 'and' part in 'where' but my results were not correct) My q...

Run sqlcmd without having SQL Server installed

I'm working on a Java program that is calling sqlcmd. It works perfectly on a computer with SQL server installed, but not at all on a computer that doesn't. I want to include the necessary exe and dll files to run this command in my jar. Anyone know which ones I need? I already included batchparser90.dll, sqlcmd.exe, and sqlcmd.dll. ...

Get Weeks in SQL

I'm certain I'm overlooking something very basic here but I can't wrap my head around it after querying and googling for about an hour. I have a datetable already in existence, if that helps. It is populated with this past years' worth of dates and is updated nightly via a stored proc that gets run by a job on the server. What I need t...

How to find out what SQL queries are being blocked and what's blocking them?

I'm trying to optimize some slow web pages, and my guess is that the problem has to do with SQL blocking (doesn't seem to be a matter of CPU or I/O utilization on the web server or database server). What's the quickest way to find out what queries are getting blocked and what queries are doing the blocking? ...

Performance - Int vs Char(3)

I have a table and am debating between 2 different ways to store information. It has a structure like so int id int FK_id varchar(50) info1 varchar(50) info2 varchar(50) info3 int forTable or char(3) forTable The FK_id can be a foreign key to one of 6 tables so I need another field to determine which ...

How to convert yyyymmddMilliseconds to datetime in SQL Server?

I got a table with some time data in the format of yyyymmddMilliseconds. For example, 20100218000051234. How to convert this into DateTime type? In SQL Server 2008. ...

SSRS 2005 or 2008 Report Model Data Caching?

Hello, Whether in SSRS 2005 or 2008, someone said that SSRS Report Model will cache the data defined within the report model and you will be required to update the report model regularly to get the new data into the report model views... is that correct? To me, it seems the report mdoel stores the definition/metdata only... could some...

SQL Server IDE/Manager

Hi, Is there any third party IDE/manager available for Microsft SQL Server Like Navicat or EMS SQL Manager which fast and good. I use EMS Manager but it is slow even on local system. Thanks ...

When dropping a constraint will the supporting indexes also be dropped?

Hello, I am trying to memorize some sql syntax and I have gotten the ALTER TABLE ADD CONSTRAINT syntax down. I believe I am correct when I say that when you use this syntax to add a FOREIGN KEY or PRIMARY KEY constraint, that sql server automatically creates indexes to support the constraint operations. (Is that true...or is it only t...

Working with a totally messy DB?!

You work for a company for a few months. You are working with a new application by yourself, application which is nicely built, that has a nice database, everything tied up together with constraints, foreign keys, etc. Suddenly you are asked to integrate your application to a very messy database. Messy in the level of: Not having a si...