Showing posts with label stores. Show all posts
Showing posts with label stores. Show all posts

Friday, March 9, 2012

Problem is forming Query

Hello,

I have a table
say SalesLeads. This table is accessed through various front -ends and
it stores data for Sales leads of various products.

This table has a reference to another table(SalesLeadRefTable)

Sample Data in SalesLeads

SalesLeadID Comments RefTableID
-----------------
1 Sample 1

Sample Data in SalesLeadRefTable

ReferenceID TableName TableFieldName
-----------------
1 ProductTable ProductID

I need to form a query which will refer to the refdtableID and form a
dynamic query like

Select Comments , TableName.TableFieldName from SalesLeads,TableName

Please let me know if this can be doen in 1 queryYou could implement a JOIN to one of many tables like this:

SELECT A.keycol, COALESCE(B.col1, C.col1, D.col1) AS col1
FROM Something AS A
LEFT JOIN Table1 AS B
ON A.keycol = B.keycol AND A.entity = 1
LEFT JOIN Table2 AS C
ON A.keycol = C.keycol AND A.entity = 2
LEFT JOIN Table3 AS D
ON A.keycol = D.keycol AND A.entity = 3

Otherwise you would have to use Dynamic SQL inside an EXEC statement.

--
David Portas
SQL Server MVP
--

Monday, February 20, 2012

problem in xp_cmdshell

Hi All,
I am new in sql server. I am taking backup of databases by
using xp_cmdshell. Can any one tell where this procedure stores the
data. I am not able to find the path for this.
If you are new to SQL Server I recommend to use the Database Maintenance
Plans to do your backups instead.
You can also directly use the BACKUP DATABASE command and schedule it in a
job.
xp_cmdshell is used to execute operating system commands so you will need to
check which commands your xp_cmdshell statement is executing.
Hope this helps,
Ben Nevarez
"mohit" wrote:

> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>
|||Hi
You don't say which version of SQL Server you are using! My guess would be
SQL Express which means that you don't have SQL Agent and that is why you are
using xp_cmdshell. If you are using a different version you could use the
backup/restore wizard and save the task as a job that can be scheduled,
otherwise check out the backup command syntax in Books Online, although SQL
Express does not come with books online it can be downloaded see
http://technet.microsoft.com/en-gb/sqlserver/bb428874.aspx for SQL 2000 see
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
John
"mohit" wrote:

> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>

problem in xp_cmdshell

Hi All,
I am new in sql server. I am taking backup of databases by
using xp_cmdshell. Can any one tell where this procedure stores the
data. I am not able to find the path for this.If you are new to SQL Server I recommend to use the Database Maintenance
Plans to do your backups instead.
You can also directly use the BACKUP DATABASE command and schedule it in a
job.
xp_cmdshell is used to execute operating system commands so you will need to
check which commands your xp_cmdshell statement is executing.
Hope this helps,
Ben Nevarez
"mohit" wrote:
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>|||xp_cmdshell doesn't store any data, it only allow you to execute some command in the OS command
interpreter. It is *what you execute* which is important.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"mohit" <goenka.mohit@.gmail.com> wrote in message
news:0987f8ee-33db-459a-92d7-073a0d494efb@.t1g2000pra.googlegroups.com...
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.|||Hi
You don't say which version of SQL Server you are using! My guess would be
SQL Express which means that you don't have SQL Agent and that is why you are
using xp_cmdshell. If you are using a different version you could use the
backup/restore wizard and save the task as a job that can be scheduled,
otherwise check out the backup command syntax in Books Online, although SQL
Express does not come with books online it can be downloaded see
http://technet.microsoft.com/en-gb/sqlserver/bb428874.aspx for SQL 2000 see
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
John
"mohit" wrote:
> Hi All,
> I am new in sql server. I am taking backup of databases by
> using xp_cmdshell. Can any one tell where this procedure stores the
> data. I am not able to find the path for this.
>