I want to pass the sort as an input parameter to the stored proc.
I am constructing a dynamic sql and executing it. The problem is more like a syntax issue, where in I an checking for certain value in sql.
Set @sql1 = '
set @sql1 = @sql1 + ' ' + @sort
How would I check for additional conditions in this sql? I tried to enclose N in double still did not work.
Customer => Customer details
=> Coloums are Customer Name, Customer Type (Gold, Silver, Platinum) Contact => Can have multiple contacts to a customer
=> Coloums are Customer Id, Name, email, Designation (D1 to D10).
we need to create an SP (MS SQL 2005 ) which returns priority 1 and priority 2 emails of customer (Customer Id will be passed as input) based on following criteria .
When Customer Type is "Gold" Customer, choose email based on following Designation
1. D1, D3,
2 D4, D6
3, D5, D7, D8
a). if D1 exist select D1 and move to set 2,
D1 NOT exist select D3 and Move to set 2
D3 NOT exist move to set 2
b) if D4 exist select D4 and move to set 3,
D4 NOT exist select D6 and Move to set 3
D6 NOT exist move to set 3
Note : if we got an email in first step and this step retun two emails. No need to iterate step 3
c) reapeat above logic with step 3 designations sequentially
Continue searching until we get 2 mails.
For "Silver" Customer choose email based on following designation
1. D1, D2,
2 D6, D7
3, D8, D9, D10
For "Platinum" Customer choose email based on following designation
1. D1, D2,
2 D8, D9
3, D3, D4, D10
I am not sure i explained logic very well. Is there any algorith for this type of logic.
Create a bridge table between CustomerType and EmailDesignation and fill it with data that represents the relationship you specified above. You can then create a query that joins these three tables to get the data that you require.
You also need to create a new table with email designations and their priority.
SELECTTOP2 C.CustomerName, Co.CustomerType, E.Email, E.Designation
FROM Customer C
INNERJOIN CustomerEmailBridge B ON C.CustomerType = B.CustomerType
INNERJOIN Email E ON B.EmailDesignation = E.EmailDesignation
INNERJOIN EmailPriority P ON E.EmailDesignation = P.EmailDesignation AND B.CustomerType = P.CustomerType
WHERE (C.CustomerID = @CustomerID)
I connected two computers in LAN 1st having IP 192.168.1.1 and 2nd having IP 192.168.1.2 and i am having sql server management studio express 2005 installed on 1st computer now when i run exe from 192.168.1.2 it throughs an error like.
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
where as it runs perfetly on 1st computer.
my conection string is
Public DBConn As ADODB.Connection
DBConn.ConnectionString = "Provider=MSDATASHAPE; Data Provider=SQLOLEDB.1;Data Source=TOSHIBA\SQLEXPRESS; Initial Catalog=" & App.Path & "\AVON_AIR_Data.mdf; User ID=sa; Password=; Integrated Security=SSPI; Persist Security Info=False;"
For remote connections, the Initial Catalog attribute must specify the database name alone, you cannot attach a local database. And the other problem is, you can either specify Integrated Security or User ID/Password, but not both.
Can any one explain how i could use Dynamic SQL using SSIS Datareader Like for
Oh this is a fun one; you will need a variable and build the syntax of your query in an expression. Then in the 'data flow', 'source editor' change, 'data access mode' to 'SQL Command from variable. It can be done, just take a little bit of creativity.
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
I want to see whether the column is created with the option, 'GENERATED ALWAYS AS IDENTITY', to make use of that in my application whether to create the record including the value for that column or not.
Can anyone please help me in getting this attribute/property from any syscolumns information from DB2 database?