INSERT INTO @TABLE EXEC @query with SQL Server 2000

N.B. – this question and answer relate to the 2000 version of SQL Server. In later versions, the restriction on INSERT INTO @table_variable … EXEC … were lifted and so it doesn’t apply for those later versions. You’ll have to switch to a temp table: CREATE TABLE #tmp (code varchar(50), mount money) DECLARE @q nvarchar(4000) … Read more

MSSQL Select statement with incremental integer column… not from a table

For SQL 2005 and up SELECT ROW_NUMBER() OVER( ORDER BY SomeColumn ) AS ‘rownumber’,* FROM YourTable for 2000 you need to do something like this SELECT IDENTITY(INT, 1,1) AS Rank ,VALUE INTO #Ranks FROM YourTable WHERE 1=0 INSERT INTO #Ranks SELECT SomeColumn FROM YourTable ORDER BY SomeColumn SELECT * FROM #Ranks Order By Ranks see … Read more

How to fix the embedded text qualifier issue while exporting data to CSV flat file?

I wouldn’t offer this answer except that you worked so hard to document it and it’s been upvoted with no answer after a month. So, here goes. Your only choices appear to be to change the data or change the tool. Probably, I am clearly doing something wrong and missing the obvious. Could someone please … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)