T-SQL (Transact Structured Query Language) is the extension of SQL functionality supported by Sybase and Microsoft SQL Server. They share the name because Microsoft SQL Server was based on Sybase code in a partnership that later dissolved. While the name is shared, functionality is not necessarily ...
1
vote
3answers
27 views
SQL ROW_NUMBER() issue with paging
I use ROW_NUMBER() function to get 50 by 50 items from database table.
@From parameter is row from which to start grabbing 50 rows. (First time it is 1 that 51,101,151 etc.)
I pass parameter @CityId ...
1
vote
1answer
21 views
How to create XML file on server using stored procedure or cursor
In my database (GoogleSEOData), I have got one Table (GoogleMarkupList) and below sample data are there in table:
PUBLICATION_ID | PAGEID | URL
...
0
votes
3answers
25 views
Sort nvarchar in SQL Server 2008
I have a table with this data in SQL Server :
Id
=====
1
12e
5
and I want to order this data like this:
id
====
1
5
12e
My id column is of type nvarchar(50) and I can't convert it to int.
...
0
votes
2answers
15 views
php explode like function in sql server 2005
I need to explode comma seperated string for reporting purpose in mssql, what i exactly need is to convert string likr 1,2,3,4,5,6,7,8,9 as below
column
1
2
3
4
5
6
7
8
9
I have been helpless so ...
5
votes
2answers
35 views
Remove dates contained within other dates?
I have the following rows:
CREATE TABLE #TEMP (id int, name varchar(255), startdate datetime, enddate datetime)
INSERT INTO #TEMP VALUES(1, 'John', '2011-01-11 00:00:00.000','2011-01-11 ...
0
votes
0answers
20 views
T-SQL, OPENROWSET copying tables between databases on the same server
I am developping some code that transfers data between SQL servers. In this phase, all my work is on the same server (local, where I am the owner), but I am already trying to implement the OPENROWSET ...
0
votes
2answers
44 views
Check value for every month in a year in T-sql using cursor
I need a example of a cursor for my meter system, where the system reads the meter every month.
The cursor needs to check, that every meter has a reading registered in the current year. For meters ...
3
votes
2answers
20 views
TSQL: Function to display month in words not numbers
MONTH(CMS.App_Received_Date) as 'App Month'
will return 4 for April when date is like '2012-04-01'
will return 5 for May when date is like '2012-05-02' etc
Is there a TSQL function to return ...
-1
votes
1answer
11 views
Insert into table variable fails with select
I get a syntax error saying this select is malformed...not sure why.
Insert into @MyTableVariable (select @new_identity, Name from Company where soemField = 'some text value')
@new_identity is just ...
0
votes
1answer
24 views
How to read config file key in SQL Server 2008 stored procedure
I have a settings.config file in my c://config
settings.config has this contents:
<filelocation>d://mydata</filelocation>
Now I want to get d://mydata file path in my SQL Server 2008 ...
1
vote
1answer
21 views
Select records but if null, show a message
I know this easy, just can't get the syntax right. If no results, show a message instead:
select COALESCE(select SomeField from SomeTable where [@SomeTableVariable].SomeID = @SomeID, 'none to ...
-2
votes
1answer
43 views
sql procedure stores multiple records of the same
My sql server database has this stored procedure...
ALTER PROCEDURE [dbo].[NewBudget]
@year int,
@int nvarchar(3)
AS
BEGIN
SET NOCOUNT ON;
INSERT [NAOLI].[dbo].[BudgetsEditTbl]
...
0
votes
5answers
34 views
SQL inline variable assignment
I have a SQL statement that determines the number of days between two dates. If the difference is negative, the statement needs to select 0. This statement works but I was wondering if it is ...
4
votes
3answers
65 views
SQL Server Convert Timestamp DataType to Decimal
Been Trying to figure this out and according to Cast and Convert Documentation on MSDN, this should be possible (
http://msdn.microsoft.com/en-us/library/ms187928.aspx )
Have a look at the Conversion ...
0
votes
1answer
12 views
User Defined Function Returns Different Result When Called from Inside Stored Procedure
I'm working in a client's SQL Server 2005 database and I'm seeing some odd behavior. I have a little experience with 2008, but this is my first battle with 2005, so I'm hoping this turns out to be ...