sql-server

Translating SQL for use with Oracle

I have 2 Oracle questions How do I translate this SQL Server statement to work on Oracle? Create table MyCount(Line int identity(1,1)) What is the equivalent of SQL Servers Image type for storing pictures in an Orace database? ...

User defined function replacing WHERE col IN(...)

I have created a user defined function to gain performance with queries containing 'WHERE col IN (...)' like this case: SELECT myCol1, myCol2 FROM myTable WHERE myCol3 IN (100, 200, 300, ..., 4900, 5000); The queries are generated from an web application and are in some cases much more complex. The function definition looks like this:...

Resources for SQL Server code review and best practices

Are there any good resources out there for T-SQL coding standards? ...

ADO.NET Entity Framework - LINQ to multiple dbms

Is it possible to create an 'Entity' that will be an abstraction of a relationship between tables that live in two different tables, in two different databases, on two different machines, and even possibly using two different dbms? For example, if I have a SQL Server db on one machine that stores all my customers, and I have an Oracle d...

Neodynamic Barcode Prfessional for SSRS

Our application needs to be able to render barcodes to PDF documents that will be accessible over the internet. Our technology stack includes Sql Server Reporting Services so we would like to leverage it and it's ability to render to PDF; however, we are not able to get it to embedded the FREE3OF9.ttf font in any consistent manner. I h...

How to get a table storage information

SQL Server Edition: SQL Server 2005 w/ SP3 and 2008 Is there a built-in SQL Server stored procedures that will retrieve following information? Or a DMV (Dynamic Management View) would be great as well. I am interested mainly on how to find out FILEGROUP data of a table specifically. But it'd be better if there was a sproc that will ret...

Tips on speeding up a SqlDataSource?

I have two SqlDataSource controls on a page. One loads high level data and the other loads more details based on which high level item you choose. It is a part of a large search that has over 900,000 records and I am looking for ways to speed it up. Whether it is options I can add onto the SqlDataSource, things I can do to the sql que...

Basic SQL / Entity Framework 1 to 0..1 entity model question

In my database I have 2 tables A and B A has columns ID, Title, and B_ID. B_ID allows nulls. B has columns ID and SomeText ID in both is primary key identity A also has a unique index on B_ID This seems like a basic way to say that A can have 0 or 1 B rows associated with it, and each B is associated with exactly 1 A. Is that correct s...

Help figuring out approaches to (near) real time multi dimensional data querying

I have a system that involves numerous related tables. Think of a standard category/product/order/customer/orderitem scenario. Some tables are self referencing (like Categories). None of the tables are particularly large (around 100k rows with an estimated scale to around 1 million rows). There are a lot of dimensions to this data I ...

How to Find the list of Stored Procedures which affect a particular column ?

Im working on this large DB which has a lot of the business knowledge embedded in the SPs[I know!] and there is a lot of chaining between the SPs. i.e one stored proc calling another. Im want to find out a list of stored procedures which update a particular column. How would I do that. Using showplan_All as outlined in http://stacko...

Need a tool to automatically indent and format SQL Server stored procedures

In my current project I've been inherited with lots of long (1200+ lines) SQL Server stored procedures with some horrible indentation and formatting which makes them almost unreadable. Is there some tool that I can use to automatically format these and make them more readable? I don't want to go through it manually and indent it. ...

Efficient way to determine whether query will return "too many records" in SQL Server

I've got a search form that could potentially return thousands of records; I'd like to show a message if the query returns more than 500 or so and make the user refine the search to get fewer results. Am I stuck with doing a Select Count before running the actual query? What's the best practice here? ...

SQL - when should you use "with (nolock)"

Can someone explain the implications of using "with (nolock)" on queries, when you should/shouldn't use it? For example, if you have a banking application with high transaction rates and a lot of data in certain tables, in what types of queries would nolock be okay? Are there cases when you should always use it/never use it? ...

Searching full-text fields in SQL Server to detect plagiarism

I'm storing papers in SQL Server 2005 and am looking for a way to paste in the text of a paper and then search for potential plagiarism (copied content) in the database. What's the best way to go about this? Is there a way to get a gauge for the extent to which something is similar to something else using full-text indexing, for several...

How can I find Unicode/non-ASCII characters in an NTEXT field in a SQL Server 2005 table?

I have a table with a couple thousand rows. The description and summary fields are NTEXT, and sometimes have non-ASCII chars in them. How can I locate all of the rows with non ASCII characters? ...

Get database name from DDL Trigger

I am creating a server level trigger in SQL 2008 to log table creation and drops. I need to log the database that the table was created in/dropped from. First I created a column with a default value of db_name(), but this always recorded master. Next I tried using this in my insert statement: EVENTDATA().value('(/EVENT_INSTANCE/Datab...

My IN clause leads to a full scan of an index in T-SQL. What can I do?

I have a sql query with 50 parameters, such as this one. DECLARE @p0 int, @p1 int, @p2 int, (text omitted), @p49 int SELECT @p0=111227, @p1=146599, @p2=98917, (text omitted), @p49=125319 -- SELECT [t0].[CustomerID], [t0].[Amount], [t0].[OrderID], [t0].[InvoiceNumber] FROM [dbo].[Orders] AS [t0] WHERE ([t0].[CustomerID]) IN (...

MS SQL 2005 "For XML Path" Node Layout Question

I have the following query Select field1 as 'node1/field1', field2 as 'node1/field2', (Select field3 as 'child1/field3', field4 as 'child1/field4' From table2 FOR XML PATH(''),TYPE,Elements) From Table1 FOR XML PATH('Root'),Elements This produces: <Root> <node1> <field1>data1</field1> <field2>data2<...

How Do You Call an MSSQL System Function From ADO/C++?

...specifically, the fn_listextendedproperty system function in MSSQL 2005. I have added an Extended Property to my database object, named 'schemaVersion'. In my MSVC application, using ADO, I need to determine if that Extended Property exists and, if it does, return the string value out of it. Here is the T-SQL code that does what I ...

Manage Test Data: Can you enlist all db connections into a single transaction?

Hi all, We are currently using Watin to do UI testing on our web application. In effect we are doing integration testing from top to bottom since we are using a test database and not mocking. In order to make sure the test database is in an expected state we have previously been using SQL Server's snapshot feature to rollback the data...