sql

WCF, Linq-to-SQL and Parameterized Constructors

How can I get WCF to allow the following? Dim EmployeeID as Integer = 10 Dim emp As New WcfServiceLibrary1.Employee(EmployeeID) Response.write (emp.LastName) Currently I have to do this because I can't figure out a way for WCF to allow for Parameterized Constructors: Dim EmployeeID as Integer = 10 Dim emp As New WcfServiceLibrary1.Em...

In .NET, Streaming data from SQL to a file

I have to get a DataTable from SQL, and then convert it to XML (I can't use SQL XML) and save to a file. The problem is that the file is going to be 5 GB, and I don't have enough memory to download it all and convert it to XML all at once in memory. I know I should be able to use a DataReader to convert and push the data to the file st...

How do I limit the number of rows returned by an oracle query?

In mysql, I do this: select * from sometable order by name limit 10,20 In which case I get the 21st to the 30th rows (skip the first 20, give the next 10). The rows are selected after the order by, so it really starts on the 20th name alphabetically. In Oracle, the only thing people mention is the rownum pseudo-column, but it is eva...

SQL function as default parameter value?

Hello everyone, First I apologise if this has been asked. I did a quick search and didn't find anything related. Here is my scenario. I tried to do this: ALTER PROCEDURE [dbo].[my_sp] @currentDate datetime = GETDATE() All the SQL pre-compiler gives me back is this error: Msg 102, Level 15, State 1, Procedure my_sp, Line 8 Incorrect ...

SQL query to return all rows where one or more of the fields contains a certain value

Is it possible to run a select on a table to quickly find out if any (one or more) of the fields contain a certain value? Or would you have to write out all of the column names in the where clause? ...

What is your preferred boolean pair: 1/0 Yes/No True/False ?

When dealing with MySQL, I typically use the BOOLEAN type, which is equivalent to TINYINT(1), or 1/0 In most languages I work with, true/false is preferred When displaying forms, sometimes "Yes / No" makes more sense ...

How to count number of different items in SQL

Database structure: Clubs: ID, ClubName Teams: ID, TeamName, ClubID Players: ID, Name Registrations: PlayerID, TeamID, Start_date, End_date, SeasonID Clubs own several teams. Players may get registered into several teams (inside same club or into different club) during one year. I have to generate a query to list all players that have...

How can I get a list of indices on a SQL table using Perl?

How can I get a list of the indices on a table in my sybase database using Perl? The goal is to "copy" all the indices from a table to a nearly identical table. Is $dbh->selectarray_ref('sp_helpindex $table') the best I can do? ...

TFS 2008: Does it come with a license for SQL Server 2008?

When you buy TFS 2008, you get a license to run SQL Server 2005 as the data repository for TFS. With SP1 of TFS 2008, SQL Server 2008 is now supported. Does any one know if the TFS 2008 license allows us to install SQL Server 2008 instead of SQL Server 2005? Are there any advantages using SQL Server 2008 over SQl Server 2005 as the dat...

ORDER BY syntax with an XML column in SQL 2005

I have a user profile(more than one profile based on user type) which I'm storing in a DB column(xml). I can query on this using XPATH in my stored procedure, however I am unsure how to then perform an ORDER BY. SELECT U.UserId, UP.Profile, UP.UserParentID FROM aspnet_Users U LEFT OUTER JOIN UserProperties UP ON U.UserId = UP.UserId W...

MySQL: What is a reverse version of LIKE?

LIKE operator in MySql is used to find rows that contain our query text, for example: select name from user where name like "%john%" which will return "John Smith", "Peter Johnson" etc. What if I need the opposite - to find rows that are CONTAINED in our query text? For example I give it "John Smith and Peter Johnson are best friends...

MS SQL to MySQL

How would this stored procedure look like in MySQL? : ========================================================================= Create PROCEDURE [dbo].[Customer_Insert] ( @CustomerID int = NULL OUTPUT, @CustomerRef varchar(25), @Name varchar(64) = NULL, ) AS SET NOCOUNT ON INSERT INTO [Customers] ( [CustomerRef], [Name] ) V...

Do I need full text search and if so how to implement full text search on sql2000?

I'm using Linq2Sql for my asp.net mvc project and so far it has worked out just great. Now however I need to implement a "key word search" that searches for x key words over about 20 fields spread over 10 joined tables that are joined with a maximum depth of 3 levels. The linq function is really simpel, but the generated query is just to...

SQLServer function for single quotes

Hello. I need to wrap a few strings in single quotes for a dynamic TSQL statement in a stored procedure. I am absolutely certain that no single quote values will be passed(these fields are not "editable" at the application level, only selectable) hence my requirements are pretty mild in this aspect. The solution I came up with is simpl...

Using LinqToSql with NLog

Hi I'm writing an .NET 3.5 web application that is using LinqToSql for the basic database stuff. I'd like to use the nLog library for logging. This library can log to a database using good ol' fashioned stored procedures (not that there is anything wrong with that..) but I'd like to use the LingToSql DataContext to log to the database ...

LINQ to SQL: What gives pain?

I decided to use LINQ to SQL in my personal project after hearing lots of goods. Is there any thing I need to taken care before start using it (during initial design)? ...

How to change the Auto Growth size? MS SQL Server 2005

In MS Sql server 2005, by default 1MB Auto Growth is there, How can i change it to whatever i need.? Thanx, Ambanna ...

DBCC CHECKIDENT Sets Identity to 0

I'm using this code to reset the identity on a table: DBCC CHECKIDENT('TableName', RESEED, 0) This works fine most of the time, with the first insert I do inserting 1 into the Id column. However if I drop the db and recreate it (using scripts I've written) and then call DBCC CHECKIDENT, the first item inserted will have an ID of 0. A...

Connection error when configuring Microsoft velocity

Hi all, I am trying to install Microsoft velocity on a machine that will use a sql database for it's configuration store. I have entered the connection string correctly but when I test the connection it fails, here are the logs: 2009-01-23 11:54:30.03 Logon Error: 18456, Severity: 14, State: 11. 2009-01-23 11:54:30.03 Logon ...

Problem with SELECT INTO using local variables

I need to create an SQL query to insert some data into a table based on the results of a SELECT query into a local variable. My DB platform is MySQL 5.1, but I don't think that should make a difference here. Basically, what I want to do is: SELECT id INTO var_name FROM table1 WHERE some_column='something' LIMIT 1; INSERT INTO table2 (...