Skip to content

Tag: sql

Creating text file without using bcp in sql

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 …

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…

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…

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…

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…