sql

how can i insert the array of id into a single field of data base

hi how can i insert the array of service id into table into a single field like 2,3,4 in database i am confuse please help followingis my code...i am using this but it is inserted only single id.. $service=implode(",",$_POST['service']); $sqlQuery="INSERT INTO ".DBPROMOTION." SET promotion_service_id='".$service."', ...

How can I write a procedure to find a set of rows like this?

Sorry about the rubbish question title. I have a table SET_DEFINITIONS like this: SETKEY NOT NULL NUMBER(38) SETENTRY NOT NULL NUMBER(38) where the idea is that the rows define sets of numbers. For example the table could contain rows: 1 2 1 4 2 1 2 2 which would mean set 1 is {2,4} and set 2 is {1,2}. I want to wr...

How can I copy a row into same table with SQL Server 2008

A) My way so far: sqlCommand.CommandText = "INSERT Table1 ([column1],[column2],[column3])" + " SELECT [column1],[column2],[column3]" + " FROM Table1 WHERE Id =" + param + ";select scope_identity() as id"; B) I wish to do something like this: INSERT INTO "table1" (* (without the ID-column)) SELECT (...

build a sql sql sytnax

+----+--------------+------+--------+---------+---------------------+----------- | Id | ip | uri | status | browser | time |refer .......... +----+--------------+------+--------+---------+---------------------+----------- int varchar varchar int varchar timeStampe varchar .............

Root cause of an "Invalid object name: dbo.etc" error?

I'm doing some maintenance programming on a fairly large project, which was started by someone who's now left the company... I've just backed up one of the company's databases, and then reattached it to our test server. That much appears to be working okay. I then go through the program's usual login procedure, and that part also appea...

Oracle VPD how to reference the table

I'm struggling with the following problem. I want to restrict access to a table using Oracle VPD. In the where clause that the select policy function returns I need a reference to the table in a subquery as follows: select * from Table t1 where not exists (select 1 from Table t2 where t2.name=t1.name and t2.date=t1.date) (The example ...

sql-Locks concept in sqlserver

I need to know about the lock concept in sqlserver why it is used ? and with any example .is there any pdf or ppt pls specify that ...

column alias oracle 10g

This seems so simple but I can't understand how do I do this query: I have a table users like this: user_id | name | role 1 | abc | a 2 | lol | b 3 | f | c and a table usersprojects (with user and project PKs) projectid | userid 1 | 1 1 | 2 2 | 2 2 | 3 How could I select all us...

SQL Server Transaction logs full, how to empty and delete them

My transaction log file is full, i have 5 log files , 2 in D: drive & 3 in E: drive. all the log file is full, each log file is 10GB in size. I need to delete all 5 transaction log file and need to have one fresh truncation log file i have tried method, 1. converted from Full to simple and shrik files (but not great effect , it does n...

Add Column on SQL Server on Specific Place?

Hello. I would like to know if there's a way to add a column to an SQL Server table after it's created and in a specific position?? Thanks. ...

Selecting nvarchar 'like' in a left join - inner join combination

I currently have a query that returns results based on a dynamic set of conditions DataTable Items: ID Title 1 Some title 2 Some other title ..etc.. . DataTable Tags: ID Tag 1 'a1c' 1 'a1d' 2 'a2c' ..etc.. My current search Query: select * from dbo.Items i LEFT JOIN dbo.tags t on i.ID...

SQL Case Sensitive String Compare

How do you compare strings so that the comparison is true only if the cases of each of the strings are equal as well. For example: Select * from a_table where attribute = 'k' ...will return a row with an attribute of 'K'. I do not want this behaviour. ...

How to rank items that match keywords by similarity

I have a table of items linked to a table of keywords. I want to list all items that share keywords and I want to rank the results so that items that are most similar appear highest. So, I figure items that match all keywords will come highest with items that match only one keyword appearing lower in the list. Where items match the sa...

SQL Get specific columns from one table and all rows from a joined table in one query

This may have been asked before and I just can't find it. I have a one to many relationship in the database on a few tables. table1 table2 table3 table2 - table3 is the 1-many relationship here's a mock of what I have: select table1.id table1.Column table2.Column2 -- I want all entries here from table 3 here as well From table1 t...

SQL: UPDATE query error value being used for column :S

I have a PHP sql command that updates a record. $tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = $waspdb, cpid = $cpid WHERE id = $id"; I'm getting an error: Invalid column name 'WaspTrackAsset_SFT'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name 'WaspTrackAss...

store data dynamically coming from database - c++

hi, Can you give me a idea about the best way that can i store the data coming from the database dynamically. I know the number of columns before, so i want to create a data structure dynamically that will hold all the data, and i need to reorganize the data to show output. In one word - when we type the query "select * from table" - re...

DBCC INPUTBUFFER;1, Retrieving Parameter info from executed SQL w/ Reporting Services

Hi all, I've been struggling with the DBCC INPUTBUFFER in SQL 2005/2008 attempting to get some information on each run of my queries. I know there are a number of other methods available that can do similar things to DBCC INPUTBUFFER, including sp_who/sp_who2, fn_get_sql(), dm_exec_sql_text, and so forth, but none of these others retur...

SQL Syntax Issues

I can't for the life of me figure out what's wrong with this sql statement select top(1) OrderNumber from (select top(5) OrderNumber from SomeTable where TreePath='tests' order by OrderNumber asc) Any Ideas? Regards, Byron Cobb. ...

How to make my SQL Server Management Studio accept a .sql file

I have a .sql file I need to enter in to my database, but I can't find how to do it. I'm using SQL Server Management Studio R2, but haven't found any options on how to add it. When I try to attach it, I'm told that this file isn't a primary database file, so I can't do it... EDIT: okay, I had the script execute. That worked. ...

mysql stored function parameter

Hi, I have just started to create a stored function this is my first time so I am having a few problems. Currently I call the fucntion using SELECT test(); (test is the function name for now). I want to send a number to the function (username ID) and have the username returned. I have this working by using SELECT test(1); 1 is the ID of...