sql

Reference to various tables

Well, I'm in a middle of some design issue. I'm trying to built kinda universal commenting system for my site. So I started with two tables: Comment_node has many Comments Now I want to be able to attach my cool comment system to various places on my site. For example to blog_posts and to user_pages. blog_posts has one comment_node ...

how to create composite primary key in SQL Server 2008

Hi am new in asp.net , i want create tables in sql server 2008, actually i dont know how to create composite primary key.CAN ANYBODY HELP ME .Advance in thanks ...

Will this get Search Engines to index my content?

I have a classifieds website... The classifieds are displayed in a dynamic php page. For instance, if one searches for "bmw m3" in the form (which is in index.html) and submits, then a php page will appear showing results. The php page called results.php, connects to mysql databases and fetches the information, and puts them in a tabl...

SQL field = other field minus an other ROW!

Table has 2 cols: [nr] and [diff] diff is empty (so far - need to fill) nr has numbers: 1 2 45 677 43523452 on the diff column i need to add the differences between pairs 1 | 0 2 | 1 45 | 43 677 | 632 43523452 | 43522775 so basically something like : update tbl set diff = @nr - @nrold where nr = @nr but i don't want...

How order results of SQL request according hierarchy level

I the context of a Java application I am using SQLIte to persist some data. One of my SQL table has the following structure CREATE TABLE containers (ID INT PRIMARY KEY, NAME TEXT, PARENT_ID INT) I need to retrieve all the containers ORDERED by hierarchy level. I.e I want first all the containers without parent (PARENT_ID == -1), then ...

How to store XML files in SQL database using C#?

Hi! I have an XML file which should be a part of a table in my SQL database (say, name, data and XML). I prefer not to make a string of it if possible. What column type should I use for it? I chose XML but I'm not sure how to work with it. A small code example would be very appreciated. Thanks. ...

Extracting e-mail addresses from Sharepoint site/database

I would like to extract e-mail addresses from a Sharepoint site/database. One list item in Sharepoint can contain several addresses inside a textbox, so I need some sort of regular expression or other trick to recognize what is an e-mail address and what is not. So I'm not sure which approach is the best. SQL Queries and/or script? ...

Set permission to DB

Hi all.. Is there any possibilities to make a Db private in sql server 2005. I mean only one user must can access and edit the others should not view and edit.. ...

Update columns with Null values

Hi I want to update a table as followings update userloginstats set logouttime= sysdate where logouttime= null; But it did not update the columns with null values. what is wrong ...

LINQ sp_executesql stmt truncated in SQL Profiler 2005 against SQL 2000 server

Background : We are using VS2008, ASP.NET .NET 3.5 and Entity Framework, with a SQL 2000 database. I am using SQL Profiler 2005 to capture LINQ sp_executesql statements on a SQL 2000 server. Problem : In SQL Profiler the sp_executesql @stmt parameter is being randomly truncated; the @stmt SQL is normally rather large as I'm querying acr...

T-SQL help with multiple unpivot

Hello I was hoping someone could help me with this I have data like this : SERVICE ITEM1 ITEM2 ITEM3 ITEM4 GOLD 0 0 0 0 SILVER 2 2 0 2 BRONZE 0 4 0 26 But want it like this: GOLD SILVER BRONZE 2 0 0 2 0 4 0 0 0 2 0 26 ...

ASP.Net/SQL dynamically add Drop down list items based on the value of a Session

I'm trying to add items to my drop down list depending on a Session or String Session("number_slept") = "8" or strNumberSlept = "8" So if that equals 8 i want to show 8 drop down list items and if it's 2 then only show 2 items etc. but I can't figure out how to do this Any ideas Thanks Jamie ...

Is is possible to get new values for Id (IDENTITY) before inserting data in a table ?

Is is possible to get new values for Id (IDENTITY) before inserting data in a table ? Is is possible to write something like that : INSERT INTO Table1 SELECT *GET_NEW_IDENTITY*, Field1, Field2 FROM Table2 I need the values of Id because I want to insert data in Table1 and, just after, insert data in another table which has a foreign ...

How to combine these two sqls into one?

I have to find out count of records which were created before 2 hours and which were created in last two hours. I can find that using [ created in last two hours ] select count(*) from trans_calc where I_TRACKING_CODE = 112 and d_entered > (current_timestamp - 2 hours) [ created prior to two hours ] select count(*) from trans_c...

Weird error when trying to add a stored procedure to PVCS

I'm trying to add an SQL stored procedure to our PVCS directory, and I'm seeing a weird error pop up. First, I get a dialog box containing ÿþC. When I click OK on this dialog box, I'm told that - An error has ocurred: The stored procedure code does not use the CREATE method. Please check your syntax. Despite the fact that my...

procedure to upload excel into sql server

Hallo All, Please help in determining the best procedure for the following problem. In a user interface, there is a provision to upload excel file. This is done by admin, once/twice in a day on a regular basis. The code that i have used to upload excel file into sql server. select * into #temp FROM OPENROWSET('Microsoft.Jet.OLEDB.4....

Optimize this SQL query's GROUP BY on a big table.

I have this query: SELECT weekno, dt, SUM(CARRYOVER) AS CARRYOVER, daycode, COALESCE('N','N') AS FLAG, DATE_FORMAT(STR_TO_DATE(CONCAT(YEAR(dt), weekno, ' Sunday'), '%X%V %W') , '%c/%d/%Y' ) AS ENDOFTHEW...

like '%' does not accept NULL value

I have query that is build from user's inputs ( passed via htm form). It looks like (simple example): Select * From [table] Where [table].[column] like '<parameter>' This parameter may be optional so if user left corresponding input field empty I pass %. It worked fine until I encountered NULL values. I understand that '%' match symbo...

Performing a prefix computation using SQL without defined procedures

I have a table with a column of integers - I need a way to generate the "prefix" of this column in another table. For e.g. I have 1, 0, 0, 0, 1, 0, 1, 0, 0 as the input I need 1, 1, 1, 1, 2, 2, 3, 3, 3 as the output This needs to be done in SQLite's SQL dialect , no user defined functions or stored procedures are possible. ...

add 2 entity from different DB with EF

Hi, does anyone know if is possible to add 2 entities into EF model from 2 DB. If not, what suggestions can you gave me to build a query that affects 2 databases ...