sql-server

Help determining proper Identity Range sizes

I have a Merge Replication with ~200 subscribers. I am trying to determine what would be appropriate Identity Range Sizes on some of the tables. You see I inherited a DB structure that was not designed for Replication therefore all table PK's are int IDENTITY's. Unfortunately some of these tables were built WITHOUT any tracking fields...

Output the text

Hi, Is there a way i can output in SQL Oracle as follow with a single quote at the beginning and end, plus a comma (,). Many thanks in advance! original output: Number 0910000001 0910000002 0910000003 0910000004 0910000018 0910000019 0910000020 Desired output: Number '0910000001', '0910000002', '0910000003', '0910000004', '09100000...

Creating custom formula on table columns

My app. is in C# 2008 and back-end is SQL Server. A table in my database has following columns: TotalAmount Discount SpecialDiscount Tax NetAmount I want my app. to be customizable by the user. A user can create a formula from the above columns to calculate NetAmount according to his need. For example: One user may use simply: (T...

SQL 2005 XML Search

Hello, I have a large XML document in Xml column within SQL Server. I need to basically perform a free text search across the elements in the document. Would you use A) SQL Free Text Search B) A stored procedure that traverses the XML and checks each value of each element C) Use Lucene.NET to build an Index on the fly and search the i...

SQL Server data to HTML layout

Hey all, I am trying this code below to be placed into my own HTML layout for export to a PDF. SELECT DISTINCT i.InvoiceNumber as 'Invoice', '$' + CONVERT(varchar(50),round((CONVERT(int,Points) * .1),0)) AS 'Amount', '$' + CONVERT(varchar(50), 1.50) AS 'Fee' FROM tblHGP HGP, OrderDetails OD, tblInvoices i JOIN tblCS cs ON i....

Help with OPENROWSET in SQL Server (Impersonation issue)

Basically I am looking to select the contents of a pdf into a table. I am using this query: SELECT * FROM OPENROWSET(BULK N'\\Server\Share\filename.pdf', SINGLE_BLOB) rs The query won't run because my username doesn't have permissions on that server (nor should it), but I need to be able to authenticate as a different user to execu...

SQL UNION on 2 table variables where date is same but other data is not

I have 2 table variable @Data and @DateTable @Data conatains the following: Company Date Type Select Altec 12-1-2010 d 2 Altec 12-1-2010 a 2 Alect 12-3-2010 d 3 @DateTable contains the following: Company Date Type Select Altec 12-1-2010 a 0 Altec ...

SQL Table Row Convert to List of Columns

What is the best way to convert a row with columns to a list with rows? In the list, I need one column with the old column name and one column with the old column value. For Example: Current: PersonId | PersonFirstName | PersonLastName | Need: ColumnName | ColumnValue Hope this makes sense. Thanks for any help. ...

How To Compare Image Data Types In SQL Server

Hi Guys, I'm having a lot of trouble writing a select statement to compare two values in t-sql which are of type image. This is what I have so far: SELECT a.UserId, b.UserId FROM [dbo].[aspnet_Profile] as a inner join [dbo].[aspnet_Profile] as b on (a.UserId = <some string> AND b.UserId = <some other string>) WHERE BINARY_CHECKSUM...

Rows to field level in query?

Hello, Using SQL 2005, I am trying to run a query on a Orders table in my database. Each order can have multiple 'Comments'. I want to get a single order record with all the Comments put together in one field. Here is the psuedocode for what I'm trying to do: SELECT Orders.Name, Orders.Date, (SELECT Comment += Comment FROM OrderCo...

Big parameter list for SQL query

Hello, I have a big list of int parameters for a SQL query: update mytable set col='xyz' where id in (/* thousands of ints */) My problem is that in SQL Server 2000 there are a limit for parameters. I could run this query on an SQL Server 2008 too. What is the better way to do this. Edit: The list of Ids come from a C# program. No...

Trouble with MS Access 2007 SQL Query

Are ordinary sql queries different from MS Access 2007 queries? I have this simple query but it is not working in MS Access query (SQL View). What is wrong with this? SELECT StudentSubject.*, Subject.*,Professor.*, Student.*, Church.* FROM ( SELECT StudentSubject.*, Subject.*,Professor.* , Student.* FROM ( SELECT StudentSubject....

Error creating dbschema file with VSDBCMD.exe

I have a VS 2010 database project that needs a database reference to a Dynamics CRM database. I have remote access to the 32-bit Windows 2003 R2 SP2 server. My strategy is to create a .dbschema file and use it as the reference. The two best resources I have found for creating the .dbschema file are http://stackoverflow.com/questions/276...

Database constraint to check against specific constraints dependent on an input value?

I'm running maintenance on a database program with no foreign key constraints, even though it really should have... There is a Logging table which has a ParentID column, and a ParentType column. The entry in the ParentType column determines which table ParentID references. What I'm looking for is for ideas on the best way to add this i...

SQL Server Recursive query

Some days ago I asked a question on SO regarding help on a recursive query. The problem of that question was "How to get the history of a Person appointments". Now I am having a problem similar to that one but it should answer to a slightly different question: How to get an Appointment history? For example if Appointment with ID = 5...

How to dynamically choose which table (with same schema) to select from in stored procedure

I have a bit of an odd database model for a project - I'm going to have several tables with the same definition. Each table stores information for different clients and because of security restrictions, we cannot put the data together in one table. So it would look something like this... table ClientOneData ( Id (PK, int, not nul...

How to access ms sql server 2008 in c?

I know little about sql server access, and all googled out for sql server accessing are using C# or php like language. Is there a good step by step about how to set up sdk and write an start program in c to access sql server database? ...

What's wrong with this SQL SELECT?

Hi, I'm using SQL Server and querying it with php. I have a query that selects data based on dates entered. $tsql = "SELECT COUNT(tblBackupArchive.StatusID) AS total, tblBackupArchive.StatusID ". "FROM tblBackupArchive INNER JOIN ". "tblBackup ON tblBackupArchive.BackupID = tblBackup.BackupID ". "W...

Return a Table of Payroll Dates from a SQL Stored Procedure

I'm working with SQL Server Reporting Services 2008, which is somewhat new to me, as most of my experience is with LAMP development. In addition, moving most of the logic to SQL as stored procedures is something I'm not very familiar with, but would like to do. Any help or direction would be greatly appreciated. I need a list of accep...

Does Microsoft's MS-SQL Server JDBC 3.0 driver include support for JTA?

Hi, I read somewhere that in order to use JTA and Tomcat (I'm also using Hibernate) you need to use a JTA version of the JDBC driver. Is this true? If so, does this driver include JTA support? Thanks, Ittai ...