i want use single quotations inside a transact sql statement, then execute that statement. for example my query is: now i want use like this: this not work, and this error occurred : Invalid column name ‘1’ I know problem is quotations in left and right side of the 1 this is a sample and i want use of this
Tag: sql-server-2008
Numbers of weekdays in a date range in TSQL
This is harder than it looks. I need a function that calculates the numbers of a given weekday in a date range. I don’t want any loops or recursive SQL. There are millions of examples doing just that. I need a fast function for calculation. Input of the function will be weekday, fromdata, todate Expected result: Answer @Mikael Eriksson has
Format() function doesn’t work?
I am trying to execute following built-in function in sql but it gives me error that this function doesn’t exist my query: Error i am getting: What may be the problem, or what am i doing wrong? Thanks! Answer Use Convert function instead. Example:
How to find out where reference to primary key is used in SQL Server?
I have a table in SQL Server 2008 R2 with primary key called ID which then is used by multiple tables around the database as foreign key. How to find out by which tables it is used? I’m trying to delete that record but it’s complaining that ID is in use. Or maybe there’s an easy way to delete all
Simple DateTime sql query
How do I query DateTime database field within a certain range? I am using SQL SERVER 2005 Error code below Note that I need to get rows within a certain time range. Example, 10 mins time range. Currently SQL return with Incorrect syntax near ’12’.” Answer You missed single quote sign: Also, it is recommended to use ISO8601 format YYYY-MM-DDThh:mm:ss.nnn[
SQL Server 2008 – How to convert GMT(UTC) datetime to local datetime?
I have an insert proc that passes in GETDATE() as one of the values because each insert also stores when it was inserted. This is hosted on SQL Azure – which uses GMT. Now, when I am receiving messages, I have the GMT date stored for each of them in their timestamp columns, how do I convert this to the
How can I group by date time column without taking time into consideration
I have a bunch of product orders and I’m trying to group by the date and sum the quantity for that date. How can I group by the month/day/year without taking the time part into consideration? 3/8/2010 7:42:00 should be grouped with 3/8/2010 4:15:00 Answer Cast/Convert the values to a Date type for your group by.
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view because it is not full-text indexed
I am getting following error in my SQL server 2008 R2 database: Cannot use a CONTAINS or FREETEXT predicate on table or indexed view ‘tblArmy’ because it is not full-text indexed.
How to find which columns don’t have any data (all values are NULL)?
I have several tables in a database. I would like to find which columns (in which tables) don’t have any values (all NULL in a column). I the example below, the result should be I don’t have any idea how to create this kind of query. Your help is most appreciated! Answer For a single column, count(ColumnName) returns the number
Join query on Date Range
HI I have following tables and so on for whole year I want the following output I need to take join between these two tables but i couldn’t figure how join condition will be look like Ragards Answer