sql

SQL Server syntax error when using OPENROWSET?

I'm trying to write this as part of stored procedure on SQL Server 2000. I keep getting a syntax error thrown on line starting Insert into OPENROWSET(..... Help! I can't see the syntax error! DECLARE @vDate Varchar(25) DECLARE @vCommand nvarchar(1000) DECLARE @fileName varchar(500) SET @vDate = LEFT(DATENAME(month, DATEADD(m, -...

Oracle hierarchical query execution steps

Here's the documentation: http://download-east.oracle.com/docs/cd/B12037_01/server.101/b10759/queries003.htm Here's the execution order it describes: A join, if present, is evaluated first, whether the join is specified in the FROM clause or with WHERE clause predicates. The CONNECT BY condition is evaluated. Any remaining WHERE claus...

How can I perform this query in oracle

Hello All, Can you please guide me to the equivalent to this query in Oracle: SELECT SQL_CALC_FOUND_ROWS * FROM tableName SELECT FOUND_ROWS() as cnt Thanks ...

FTS Sql Server 2008 question - assign weights to multiple columns

I have a feeling this question might have been asked before, but I am not able to find it. So here it goes: I am searching through articles for words, phrases typed by users on a website my articles have different columns for title, keywords, body, summary. when I am searching I want the result to be more relevant if found in Title tha...

SQL query with specialized ordering of results

I have a table that has 3 columns representing the stops in a bus route. ID stop_name stop_order I am wanting to return a list of stops starting with the current stop (which I know). So if the current stop is stop number 5 then what is returned will be as follows: stop_order 5 6 7 8 1 2 3 4 I tried: Select * from routes where stop...

How to get this information when executing queries?

I'm looking for this information when executing queries: # Query_time: 11.639269 Lock_time: 0.000192 Rows_sent: 2 Rows_examined: 6509098 How can I get this from the command line? ...

I am having trouble getting the correct results using XML EXPLICIT in T-SQL (SQL Server 2008)

I am getting strange results from a query using XML EXPLICIT mode in T-SQL (SQL Server 2008). Can someone explain what I am doing wrong? Here is my example: declare @parents table(id int, connection int, title nvarchar(255)); declare @children table(id int, connection int, title nvarchar(255)); insert into @parents(id, connection, ti...

'Printing' from a SQL 2008 R2 trigger

If I have PRINT 'something' in a trigger, where does that output go? I'm using SQL Server 2008R2 ...

VS/SQL Mgmt Studio question - how to stop VS from opening a new SMS for each .sql file

In my Visual Studio project I have a folder containing a number of .sql files. I have set VS to open these files with SQL Management Studio by default. The problem is that a new instance of SMS is started each time a .sql file is opened. This is really annoying when doing a project-wide Find in VS, when VS opens every single .sql file - ...

How many constraints can be given to a column of a table in SQL Server

Hi, Can anyone explain me how many constraints at most can be set on any given column of a table in SQL Server. ...

How to merge 3 cells content in one in excel or by using sql

I have an excel csv file that i am uploading to sql server table using sqlbulkcopy,data in excel looks like this 121 **ABCDEFG** 138.00 141 XYZ **HIJKLMN** **OPQRSTUV** So basically this 3 line make a single record in table,how should i merge these 3 line comments in one ? ...

How to change Entity Framework schema during runtime?

How can you change the schema that is defined in the ssdl files generated by the Entity Framework at runtime? I understand that this is not support out of the box and I don't want to use any external projects (like the one suggest here). ...

C# if statment help with droptdownlist.selectedvalue

so I am connecting a sql database. I have a asp.net page and when the user selects the dropdownlist for status and selects the value to Closed, Then clicks update ticket button, i need it to take update the Closed_date column in the table. my table has the column Closed_Date type datetime. I have a stored procedure that updates that c...

SQL Server adding values

Hi, SELECT @s = ISNULL(@s + '. ' , '') + [Comments] FROM [Customer] RETURN @s How can I catch Null or '', so that if its either It Won't append to the string and not add a '.' Thanks Jacob ...

MySQL query incorporation both join tables and nested sets

I have three tables, categories, tags, and taggings. The categories table is put together in the fashion of a nested set, with relevant columns id, lft, rgt, and parent_id. Tags has id and name. Taggings has tag_id and taggable_id, which refers to categories.id. If possible, I'd like for one query which returns in a field, say tag_list,...

Creating a flattened table/view of a hierarchically-defined set of data

I have a table containing hierarchical data. There are currently ~8 levels in this hierarchy. I really like the way the data is structured, but performance is dismal when I need to know if a record at level 8 is a child of a record at level 1. I have PL/SQL stored functions which do these lookups for me, each having a select * from tb...

Implementing a per-model table modification time in Django?

I have a Django application which edits a database table, which another application polls and uses to update a downstream system. In order to minimize processing when the database has not been altered in between polls, I would like to use a global modification time for a model, which is updated every time a row is created/deleted/modifi...

Custom function in Entity Framework query sometimes translates properly, sometimes doesn't

I have this function: public static IQueryable<Article> WhereArticleIsLive(this IQueryable<Article> q) { return q.Where(x => x != null && DateTime.UtcNow >= x.PublishTime && x.IsPublished && !x.IsDeleted); } And it works just fine in this query: from a in Articles.WhereArticleIsLive() where a.Id ==...

TSQL CASE WHEN THEN SYNTAX - USING REPLACE

Hi there, This actually applies to a prior question, TSQL 2008 USING LTRIM(RTRIM and Still Have Spaces I am at the point of writing a very lengthy SELECT statement using OMG PONIES statement to remove NON NULL non visible characters (WHEN PropStreetAddr is NOT NULL THEN (SELECT LTRIM(RTRIM((REPLACE(PropStreetAddr, ...

SQL - Multiplie one-to-many relationships

Is it possible somehow to do multiplie one-to-many relationships between 2 tables? Like: Table abc abcID defID message Table def defID abcID message If yes how can I then make a new abc entry with the entity framework? ...