I've had this come up a couple times in my career, and none of my local peers seems to be able to answer it. Say I have a table that has a "Description" field which is a candidate key, except that sometimes a user will stop halfway through the process. So for maybe 25% of the records this value is null, but for all that are not NULL, it ...
Is anyone aware of a T-SQL script that can detect redundant indexes across an entire database? An example of a redundant index in a table would be as follows:
Index 1: 'ColumnA', 'ColumnB', 'ColumnC'
Index 2: 'ColumnA', 'ColumnB'
Ignoring other considerations, such as the width of columns and covering indexes, Index 2 would be redunda...
I run this command:
gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org
and it fails with
ERROR: Could not find a valid gem 'activerecord-sqlserver-adapter' (>= 0) in any repository
How can I install the Microsoft SQL Server adapter?
...
Hi,
I have three tables in sql, CUSTOMER, ISSUE, ISSUE_NOTES.
SELECT CUSTOMER.name, ISSUE.description, ISSUE_NOTES.notes
FROM CUSTOMER, ISSUE, ISSUE_NOTES
WHERE CUSTOMER.customer_id = ISSUE.customer_id
AND ISSUE_NOTES.incident_id = ISSUE_NOTES.incident_id
This will produce a row for each issue_notes field that's populated. (field is...
Have a DTS package that is running in Development, SIT, and UAT. All of the SQL Servers in each of the environments has the same linked servers setup and are the tech specs similar. The DTS package takes different amounts of time to execute. The package should take about 3 hours to run. There are indexes on the tables that are access...
For you database design/performance gurus out there.
I'm designing a table, I have the choice of either use int or nvarchar (128) for a column, assume space is not a problem. My question is which will give performance
when I search with int column
where ID = 12324
or when I search with nvarchar column (the Key is the entire value, ...
I'm working with a database (let's call it DB_data) that contains all of the tables for a series of applications. In an attempt to minimize downtime during upgrades, a facade database (let's call it DB_facade) has been created which has a view for each of the tables in DB_data. It also contains all of the functions and stored procedures,...
Let's say I have two databases with identical tables, but one database's tables contains data while the other doesn't. Is there a way in SQL Server to generate a script to fill the empty tables with data from the full tables?
...
I am linked to a Proficy Historian that allows periods in the column names. Because the data is stored in a non DBMS format I can not use openquery to get the data because there is no set schema to the tables. So I must use four part name syntax to get the data. This example works:
SELECT * FROM iHist...[SELECT * FROM ihTrend]
but ...
If I want to run this sort of query in SQL Server, how can I do the same query from one server I am connected to to another?
I tried adding "[ServerName1]." before "[DatabaseName1].[dbo]..." and "[ServerName2]." before "[DatabaseName2].[dbo]..." but that didn't seem to work.
INSERT INTO [DatabaseName1].[dbo].[TableName]
([Fi...
Hi
I am trying to use the package/publish sql in VS 2010. So I went through this tutorial
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28WEBAPPLICATIONPROJECTS.DEPLOYSQLWALKTHROUGH%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29&rd=true
I imported the connection string from...
I'm working with SQL Server and I'm pretty new to SQL in general, so if this is a very trivial question, please bear with me.
I have a table in a database with a datetime field representing some timestamp. When extracting the table via a SELECT statement, I would like to have a column of True/False representing whether or not the row ha...
We have a client environment that has MSDE. We're looking to install SQL Server 2008 Express on the clients but must retain MSDE for other applications.
Assuming both MSDE and SQL Server 2008 Express exist on a single machine what options are available to copy a database from MSDE to SQL Server 2008?
Suppose that MSDE may or may not be...
A co-worker had told me that he thought it was possible to store/access log4net's config file in a database rather than a standard config file. If it's possible, how would you go about doing this? Google search seems to be failing me.
...
I am tracking clicks over three time periods: the past day, past week and past month.
To do this, I have three tables:
An hourly table, with columns link_id, two other attributes, and hour_1 to hour_24, together with a computed column giving the sum
A weekday table, with columns click_id, two other attributes, and day_1 to day_7, toge...
Hi everyone,
I have read through some excellent responses already dealing with SQL XML output posts, although what I need might not be a) best to do within a stored proc and b) not possible within a stored proc.
My question is this:
I have a simple table; col1, col2, col3, col4 .. for the purpose of an example, they are all just varch...
select *
from table
where date > '2010-07-20 03:21:52'
which I would expect to not give me any results... EXCEPT I'm getting a record with a datetime of 2010-07-20 03:21:52.577
how can I make the query ignore milliseconds?
...
Hi
I want to copy N number of records within a table which is easy with a INSERT SELECT however after the insert I want a list showing oldId and newId. So lets say I have a SELECT statement which returns:
ID | Name
3 | Test A
4 | Test B
5 | Test C
If I do a SELECT INTO from this it inserts 3 new PKs. I want a list showing the new ...
Can someone help me with SQL Server CAST to text datatype? I'm trying to get the long text to display using the CAST function, but it wont work if I am retrieving from more than 1 table. Perhaps I've created the statement incorrectly.
$from = 'RealEstate AS RE, Models AS M, Catalogue AS C';
$select = 'CAST(RE.Details AS TEXT) AS RE.Det...
Hi there
I have 3 column (ID, Start and End) in TSQL.
ID; Start; END
1; 1; 5;
2; 10; 15;
So it will generate number like:
1, 1
1, 2
1, 3
1, 4
1, 5
2, 10
2, 11
2, 12
2, 13
2, 14
2, 15
Again all I can think of is cursor but is there any better way?
...