I have to query a table and print the output in a text file. I have a normal user login with dbo permission on the database. I cannot use bcp or cannot give any special permissions. Can anyone help me with this? Answer You can’t create a text file on the server or elsewhere with only permissions in the …
Tag: sql
Android – sqlite in clause using values from array
I want to execute a sqlite query: The values in the in clause need to be taken from an array of strings: How can I achieve that? Answer I believe a simple toString() will mostly do the trick:
Index for nullable column
I have an index on a nullable column and I want to select all it’s values like this: In the explain plan I see a FULL TABLE SCAN (even a hint didn’t help) Does use the index… I googled and found out there are no null entries in indexes, thus the first query can’t use the index. My ques…
insert into values with where clause
I am trying to programmatically enter values into my table. I cannot use a straight Select @variables. I have to use the keyword Values. How can I create a where clause when using Values in the insert into. I am trying to avoid duplicates Answer
How to copy a row and insert in same table with a autoincrement field in MySQL?
In MySQL I am trying to copy a row with an autoincrement column ID=1 and insert the data into same table as a new row with column ID=2. How can I do this in a single query? Answer Use INSERT … SELECT: where c1, c2, … are all the columns except id. If you want to explicitly insert with an
How to calculate the slope in SQL
I have some data in a sql database and I’d like to calculate the slope. The data has this layout: I’d like the final output to look like this by creating a new table using SQL: To complicate things, not all Keywords have 3 dates worth of data, some have only 2 for instance. The simpler the SQL the…
Simple update query is taking too long
I have a table CurrentStatus in my database (subscription database in a merge replication) Columns are StatusID {Primary Key + Clustered Index}, StatusName, StatusDate, UserID,CreatedDate, …
Select statement in SQLite recognizing row number
I want to write SQLite statement something like this: but i don’t have such column RowNumber. I have primary key in my table. But is there row number by default that i could use ? Also i am searching info about writing more complicated SQLite statement. So if you have some links in bookmarks please shar…
How to select info from row above?
I want to add a column to my table that is like the following: This is just an example of how the table is structured, the real table is more than 10.000 rows. So for every time there is a value in ‘Subgroup’ I want the (New_Column) to get the value [No_] from the row above There are cases where
SQL Server – Cursor
I am trying to loop through a table using a cursor: That above returns taskResourceOID and EvUserOID. If I need to output a table with the @TaskOID and the respective taskResourceOID and EvUserOID, what is the best way to do it? Answer Use a temporary table or a table variable.. Or even better, don’t us…