[Solved] Cant locate SQL syntax error in basic email tracking pixel [closed]

You appear to have an extra comma at the end: INSERT INTO email_table VALUES (‘$CAMPAIGN’, ‘$IP’,) Try: INSERT INTO email_table VALUES (‘$CAMPAIGN’, ‘$IP’) BTW, I won’t judge your code too much but tracking people by IP is not very reliable. For example, a lot of corporate traffic behind company firewalls can use the same IP … Read more

[Solved] How can I sort between characters and numbers in column [closed]

Here is another option Example Select Robot_Type from (Select distinct Robot_Type From YourTable ) A Order By try_convert(int,left(replace(Robot_Type,’IRB’,”),patindex(‘%[a-z,/]%’,replace(Robot_Type,’IRB’,”)+’a’)-1)) ,Robot_Type Returns Robot_Type NULL IRB 120 IRB140 IRB 360 IRB 910SC —<< Disconnect from your desired results IRB 1200 IRB 1410 IRB 1520 IRB1600 IRB1600/1660 IRB1600ID IRB1600ID/1660ID IRB1660ID IRB 2400 IRB 2600 IRB 4400 IRB 4600 IRB … Read more

[Solved] Generate column Alias name dynamically in MS SQL Server [closed]

create procedure my_procedure (@col_alias varchar(100)) as declare @my_stmt nvarchar(max) = N’select 1+1 as ‘ + @col_alias exec sp_executesql @stmt = @my_stmt exec my_procedure @col_alias=”[This is a dynamix col alias]” This is a dynamix col alias ————————— 2 15 solved Generate column Alias name dynamically in MS SQL Server [closed]

[Solved] Simple VBA Select Query

Here is one way to do it: sSQL = “SELECT Variable FROM GroupTable ” Set rs = CurrentDb.OpenRecordset(sSQL) On Error GoTo resultsetError dbValue = rs!Variable MsgBox dbValue, vbOKOnly, “RS VALUE” resultsetError: MsgBox “Error Retrieving value from database”,VbOkOnly,”Database Error” solved Simple VBA Select Query

[Solved] how to reverse a sequence [closed]

For Sql Sever Select Row_Number() Over(Order By [EMP_NO] Desc) as Emp_No, EMP_NAME from TableName Order By [Emp_No] Desc Sql Fiddle Demo For Oracle Sql Developer Select Row_Number() Over(Order By “EMP_NO” Desc) as “Emp_No”, “EMP_NAME” from Table1 Order By “Emp_No” Desc Sql Fiddle Demo 18 solved how to reverse a sequence [closed]

[Solved] SELECT COUNT TROUBLE IN QUERY [closed]

I think you need a query like this: select censusyear, sum(case CitycenGender when ‘Male’ then 1 else 0 end) as ‘Total Male’, sum(case CitycenGender when ‘Female’ then 1 else 0 end) as ‘Total Male’ from CitycenTable inner join CensusYearTable on CityCensusYear = CensusYearID Regards. 2 solved SELECT COUNT TROUBLE IN QUERY [closed]

[Solved] Get previous month in SQL when given a varchar

Try this: DECLARE @dt VARCHAR(8) = ‘201501’ SELECT LEFT(CONVERT(VARCHAR(8), DATEADD(m, -1, @dt + ’01’), 112), 6) Output: 201412 Using DATEADD you can calculate the previous month. This function conveniently accepts a string as an argument. CONVERT is then used to convert the result back to yyyymmdd format. 1 solved Get previous month in SQL when … Read more

[Solved] What’re the purposes of these special characters in SQL injection?

This value: admin’);# would terminate the SQL statement after the string “admin” and treat everything after as a comment. So this: SELECT ID, name, locale, lastlogin, gender, FROM USERS_TABLE WHERE (name=”$user” OR email=”$user”) AND pass=”$pass” essentially becomes this: SELECT ID, name, locale, lastlogin, gender, FROM USERS_TABLE WHERE (name=”admin”) A record is found and the system … Read more

[Solved] What is returned when I count nulls?

What you do is use a conditional SUM SELECT SUM(CASE WHEN field IS NULL THEN 1 ELSE 0 END) as numNULL, SUM(CASE WHEN field IS NULL THEN 0 ELSE 1 END) as numNOT_NULL, FROM table EDIT Sorry if i missunderstand your question. But your comment is very different to you original question. http://www.w3schools.com/sql/sql_func_count.asp SQL COUNT(column_name) … Read more

[Solved] SQL parameters not working

You’re not actually running the command. You need to call ExecuteNonQuery or ExecuteScalar: using (var cmd = new SqlCommand(query, conDataBase)) { // set parameters… cmd.ExecuteNonQuery(); } 1 solved SQL parameters not working

[Solved] Get all values from SQL Server [closed]

Simply take out the MAX() function and add this column in your group by clause , happy days…… SELECT [b_BookNum] ,[b_CHMAT] ,COUNT(*) iCount FROM MPA.dbo.SCHM_Books GROUP BY [b_BookNum] ,[b_CHMAT] ORDER BY [b_BookNum] EDIT I am surprised that you have all the information you need to solve the problem and yet you are so incompetent to … Read more