Any updates in SQL 2008 to allow a variable for the IN of a where clause?
Declare @InParams varchar(100)
Set @InParams = '1,2'
Select * from Category
Where CategoryID in @InParams
Hi,
I have an app and I have come to a point where I need to build a
sql statement up dynamically.
Is there a way to execute it and return a type that has not been defined
via the designer with Linq2Sql??
Malcolm
When using a SQL join, is it possible to keep only rows that have a single row for the left table?
For example:
select * from A, B where A.id = B.a_id;
a1 b1
a2 b1
a2 b2
In this case, I want to remove all except the first row, where a single row from A matched exactly 1 row from B.
I'm using MySQL.
Is there a tool or code to convert a sql statement to class?
Something like:
Dim sqlText = "SELECT CustomerID, Name, Address, City FROM dbo.Customer WHERE CustomerID = 1"
Dim obj As New ***SqlStatementTool***(sqlText)
obj.GetTables() 'Will Return Tables in sqlText
obj.GetWheres() 'Will Return conditions in sqltext
obj.GetParameters() 'will return parameters in sqltext
I have 3 computers having the same sql server 2005 database, i would like to gather the data from the 3 computers to another computer which has the same database.
pls help me tnx in advance
I need to convert a number which gives decimals in factored format in to decimals,
i.e. 11.16 is 11.5 in decimal. This is because 16 is in base of 32 and 11.16 should be read as 11+16/32 = 11.5
I get 11.16 as a string and I need to change it to 11.5 as numeric in MS SQL(2005) database.
Any shorter way of doing this rather than splitting strings,converting to numerics,maths,convert to string, concatenate and then convert to numeric?
I need help converting this SQL statement, into EF4:
Select Posts.PostID, Post, Comment
from Posts left join
Comments on posts.PostID = Comments.PostID
Where CommentID not in
(
Select PostID
from Votes
where VoteTypeID = 4 --4 = flagged comment type
)
In my database, the Votes table stores either the PostID of reported posts, or CommentID of reported comments in the column Votes.PostID
Thanks in advance!
I'm building a windows mobile app. And using SqlCe.
I'm looking for a good sql query builder. So instead of writing "SELECT COLUMNS FROM TABLE WHERE etc...
Is there a good free library that can build this sort of query?
hi,
i would like to compare numeric data in rows. for eg, i have a table that has a column as such:-
Number
======
1.88
9.99
8.76
9.88
I want to compare 2nd value, 3rd value, 4th value to the 1st value. And then 3rd, 4th value to the 2nd. then 4th to 3rd.
How can i construct an sql to do this?
I have been playing around with creation of pdf documents for a project that I'm working on. I would like to store the generated pdf document in a SQL database and then later be able to retrieve this pdf as well.
What are some suggestions for doing this? Can the document be stored in the database without physically creating the document on the server?
I am using the below statement to generate age of a person in Oracle SQL and my question is below.
SELECT TO_NUMBER(TO_CHAR(CURRENT_DATE,'YYYY'))-TO_NUMBER(TO_CHAR(BIRTH_DATE,'YYYY')) FROM NAME WHERE NAME_ID =NAME_ID
This statement is only correct upto so far that I need a statement which could count months and even days in order to get the age.
Please explain, in plain English, what question this SQL query answers:
SELECT SUM(price) FROM Room r, Hotel h
WHERE r.hotelNo = h.hotelNo and hotelName = 'Paris Hilton' and
roomNo NOT IN
(SELECT roomNo FROM Booking b, Hotel h
WHERE (dateFrom <= CURRENT_DATE AND
dateTo >= CURRENT_DATE) AND
b.hotelNo = h.hotelNo AND hotelName = 'Paris Hilton');
Hi,
I have a project in C# with a Sql-server Database.
In that database I have a table named 'Process' and columns named 'process_name', 'Full_Name' and 'Version' (all of the type:nvarchar(50)).
I want to write a query wich will add the new process, only if it doesn't exist in the table yet.
How can I do that?
Many thanks,
Since @A is never declared, sql server should throw an error, but it doesn’t. Why is that?
DECLARE @i int = 1;
IF @i > 10
BEGIN
DECLARE @A int = 100;
END
PRINT @A; // doesn't return any result
thanx
Hi I need some sample SQL Server Employee database with data such as id, surname, name, age, adress etc. It must be quite big, I search with google, but I don't find any good sample.
Can any body help ?
I'm trying to execute this on MS-SQL but returns me an error just at the Group by line
update #temp
Set Dos=Count(1)
From Temp_Table2010 s
where Id=s.Total and s.total in (Select Id from #temp)
group by s.Total
Do anyone knows how can I solve this problem having good performance.
hi!
I've a table(TableA) with contents like this:
Col1
A
B
B
B
C
C
D
i want to remove just the duplicate values without using temporary table in Microsoft SQL Server. can anyone help me?
the final table should look like this:
Col1
A
B
C
D
thanks :)
How do I return the everything in a string from a sql query before a certain character?
My data looks like this:
HD TV HM45VM - HDTV widescreen television set with 45" lcd
I want to limit or truncate the string to include everything before the dash.
So the final result would be "HD TV HM45VM"
Hello,
I have a table structure that looks like this:
ID String
-----------
1 A
1 Test
1 String
2 Dear
2 Person
I need the final output to look like this:
ID FullString
--------------------
1 A, Test, String
2 Dear, Person
I am really lost on how to approach this... I looked on a couple examples online but they seemed to be VERY complex... this seems like it should be a real easy problem to solve in sql.
Thank you for all assistance!
I have read many strong views (both for and against) SPs or DS.
I am writing a query engine in C++ (mySQL backend for now, though I may decide to go with a C++ ORM). I cant decide whether to write a SP, or to dynamically creat the SQL and send the query to the db engine.#
Any tips on how to decide?
Reading about both Linq to SQL and Entity Framework I have developed the impression that EF is more suitable for apps that get data from multiple data sources.
But as I am reading about MVC2 models I see an example where EF is more loosely coupled with your data model.
If I have to add or remove some columns from a table then what is involved in updating my model or DAL with each of these implementations?
Does any one know of an example on how to store an image in a SQL Server CE database?
What data type should the column be? (I am guessing binary.)
I use Linq-To-Datasets. Is it possible using that to put the image into the database and pull it out again later?
Thanks for any advice.
So I am trying to change the number of fields in my dataset in SSRS and the refresh button is not picking up the added field from the SQL server. The query is definitely returning the correct data, as I have double checked in the server engine itself. Also, I have tried manually adding the field using the SSRS menu, but as soon as I execute it disappears.
Any suggestions or similar experiences?