I'm trying to learn SQL to store the data rather than reading the file and populating the whole data structure in memory. would it be like reading the data from disk instead of direct memory?
Hi,
I want to develop a function in PHP that checks how dangerous a SQL statement is. When i say dangerous i mean, certain symbols, characters or strings that are used to get data from a database that the user shouldnt see.
For example:
SELECT * FROM users WHERE userId = '1'
can be injected in several ways. Although i clean the params, i also want to monitor how safe the query is to run.
Thanks in advance
I was wondering if there was any recommended max size for MDF and/or LDF Files for an SQLserver instance.
For example, if I want to create a 400 GBytes Database, is there a rule to help me decide how many mdf files I should create ? or should I just go ahead and create a single gigantic 400Gbytes mdf file?
If so is this going to somehow affect the database performances ?
Hi,
I have the following table in an access database
id VisitNo Weight
1 1 100
1 2 95
1 3 96
1 4 94
1 5 93
Now row 2 and 4 are deleted. So i have...
id VisitNo Weight
1 1 100
1 3 96
1 5 93
However what i need is...
id VisitNo Weight
1 1 100
1 2 96
1 3 93
What is the SQL query i need to accomplish the above?
thanks
We need to INSERT 2000 records into SQL DB from C# .Net code.
For this is there any way to INSERT all 2000 records at a time instead of executing the INSERT query for each record.
Also how would be the performance impact of doing this?
Thanks & Regards
Padma
Was wondering if any one could recommend any and all books for learning more about SQL and DB concepts?
I found this one while browsing SO, but was wondering if anyone had other or more up to date recommendations?
I simply want to include a row number against the returned results of my query.
I found the following post that describes what I am trying to achieve but gives me an exception
http://vaultofthoughts.net/LINQRowNumberColumn.aspx
"An expression tree may not contain an assignment operator"
In MS SQL I would just use the ROWNUMBER() function, I'm simply looking for the equivalent in LINQ.
From here
ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID);
How do i add several keys with SQL Server? is it something like the below? (I cant test ATM and unfortunately i have no way to test queries unless i run it through code)
ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid) REFERENCES CUSTOMER(SID),
ADD FOREIGN KEY (customer_sid2) REFERENCES CUSTOMER(SID2);
or is it like
ALTER TABLE ORDERS
ADD FOREIGN KEY (customer_sid, customer_sid2) REFERENCES CUSTOMER(SID, SID2)
We are switching from a SQL cluster to a mirrored solution. The problem is that we have a bunch of programs that would have to switch connection strings to handle the failover. Is there any way the we can set up a redirect or proxy that would take any legacy requests and forward them to the mirrored solution?
Hi,
i've coded a tiny forum software in php where people posts threads, and i want to support tags.
How many SQL tables should i make for this ? and briefly how the tags system will work?
Thanks
Is there an easy way to do a find and replace on a string in every view and stored procedure in my SQLServer database.
I need to replace something like 'X United Kingdom' with 'X(UK)'.
i have two tables
table1 fields
fid,fname,fage
a ,abc ,20
b ,bcv ,21
c ,cyx ,19
table2 fields
rcno,fid,status
1 ,a ,ok
2 ,c ,ok
3 ,a ,ok
4 ,b ,ok
5 ,a ,ok
i want to display rectors like this
fid from table1 , count(recno) from table 2 and fage from table1
fid,count(recno),fage
a ,3 ,20
b ,2 ,21
c ,1 ,19
i try many sql queries but got error
Thanks
i am going on a job interview and have zero experience with ms sql, however i have 1 year with oracle. is there such a huge difference between the two? what programming questions can i expect?
I need to get a list of all tables that are published for replication from MS-SQL 2005/2008 databases. Is there a system stored procedure or a query I could run to generate such a list?
Thank you,
I have created a table with the following structure-
$sql = "CREATE TABLE followers
(
uid int UNSIGNED NOT NULL UNIQUE,
PRIMARY KEY(uid),
follower_count int UNSIGNED ,
is_my_friend bool,
status_count int UNSIGNED,
location varchar(50)
)";
I need to find the uid of the person with max(status_count+follower_count) and whose is_my_friend = 1
I wrote the following query but I ain't getting the correct uid.
SELECT p.uid FROM (select uid,is_my_friend,max(follower_count+status_count) from followers) p WHERE p.is_my_friend = 1;
Hi Friends,
I need to run a profiler on SQL 2005 to capture the SPs with which took longer than 1/10th of a second. Can you please let me know how can I do that. I dont see the option. Also in the duration is that measured in second or minute.
I would apprecaite your help.
Thanks,
I have table with 3 columns(smallint) in MS SQL 2005.
Table Ratings
ratin1 smallint,
ratin2 smallint
ratin3 smallint
These columns can have values from 0 to 5
How to select average value of these fields, but only compare fields where value is greater then 0.
So if column values are 1,3,5 - average had to be 3
if values are 0,3,5 - average had to be 4
I have problem using IIS 7 and SQLServer 2008. When I trying to show my website using IIS as webserver I get the message "[SqlException (0x80131904): Login failed for user..."
When I using the webserver included in Visual Studio 2010 to show same website there is no problem to access the database.
Why is it working with VS2010 webserver but not with IIS?
We have been having problems with ghost updates in our DB (SQL Server 2005) fields are changeing and we cannot find the routine that is updating. Is there a way using an update trigger (Or any other way) to tell what caused the update?
SELECT COUNT(*) AS Expr1
FROM Book
INNER JOIN Temp_Order ON Book.Book_ID = Temp_Order.Book_ID
WHERE (Temp_Order.User_ID = 25)
AND (CONVERT (nvarchar, Temp_Order.OrderDate, 111) = CONVERT (nvarchar, GETDATE(), 111))
In here i want to change my User_ID to get from a label.Text
this Sql Statement is in a DataView. so in the Wizard it not accepting a text box values or anything.
can someone please help me to solve this
I am trying to fetch records based on two dates from sqlserver...
Select * from table where CreatedDate between @StartDate and @EndDate and i pass 5/12/2010 and 5/12/2010 (ie) fetching records for today... I have 17 records dated 5/12/2010 but none seems to get selected....
EDIT:
I use this but when i debug my value it shows 5/12/2010 12:00:00AM
DateTime baseDate = DateTime.Today;
var today = baseDate;
GetBookingReportByDate(today,today);
I have a local instance of SQLServer 2008 express edition running on my development PC. I'm trying to create a new data connection through Visual Studio Server Explorer.
The steps are the following:
Right click the "Data Connections" node = Choose Data Source.
I select "Microsoft SQLServer" as the data source.
The "Add Connection" dialog window appears. I select my local server instance = "Test connection" works fine.
I select "AdventureWorks" as the database name = "Test connection" works fine.
Next I hit the "Ok" button = Error message: "This server version is not supported. Only servers up to MS SQLServer 2005 are supported."
I'm using Visual Studio 2008 Professional Edition. The target framework of the application is ".NET framework 3.5". I have a reference to System.Data (framework v2.0) and cannot find another version of the assembly on my system.
Am I referencing the wrong assembly? How can I fix this problem?